Designer Javascript support
Designer Javascript References
JavaScript can be used in your workflow forms where InfoPath functionality does not exist or is not supported in the browser. This can be used to do calculations, custom validations, or any other modification of the Form's XML data.
Client-side JavaScript is supported in forms, although not in the way that native InfoPath supports it. InfoPath is a client, and supports a more feature-rich version of XML than a Web browser, so there are limitations and differences when using it with a Winshuttle Designer form.
Note: Nested functions are not supported, such as
SVStringLength('/my:myFields/my:partRevision', 'normalize-space(.')<--) > 2
Please note that Winshuttle Support can not help you create or troubleshoot javascript. In addition, jQuery is not supported.
Editing custom JavaScript through InfoPath
Javascript can be accessed in InfoPath design mode via the menu Tools | Programming | Microsoft Script Editor.
The comment tag ShareVisBeginScript marks the starting point for the script. The comment tag ShareVisEndScript marks the ending of the script. The code in between the markers is what is extracted and loaded into the browser when the form is loaded. (These must be commented so that InfoPath does not report syntax errors in the JavaScript.)
The global variable SVViewName is set to the view name of the current view. It can be used to run code in specific views.
The function SVFormXmlChanged is called after each modification of the form with the argument being the XML document representing the form data. This XML document's schema is the schema built by InfoPath when you defined your form.
SVFormXmlChanged is passed to a ShareVis Javascript object that wraps the native XML document class that exists in the browser. Your interaction with the XML document should be through this wrapper so that different browsers and browser versions can be supported seamlessly without changes to your own code. See the Web help pages (left) for more information about each of the JavaScript callback functions and their associated arguments.
Winshuttle Designer Javascript Wrappers
To maintain browser and browser version compatibility, Winshuttle Designer uses Javascript wrapper objects to allow you to interact with XML documents and nodes. You should only use these objects to interact with the underlying XML objects so that you can be assured of not having to change your own code when new browsers or browser versions are introduced.
Solution example (download)
The following file contains a basic InfoPath form and Designer solution file you can use as an example of using Javascript in a Designer-based workflow/form solution.
To use the example file:
- Create a new site called /jstest.
- Publish the JS Calc.xsn Form to /jstest.
- Publish the workflow JS Calc.svp to /jstest.