Form designer: How to create global JavaScript functions?

Question

Is there a way to create a JavaScript file that would automatically be included with every form that is built?

I know I could create a script and manually add it to each form through the Form Configuration dialog, but I was hoping I’d be able to apply it globally.

The reason is that I’m thinking of creating some user controls that would utilize JavaScript to render them to the page that I would possibly utilize on nearly every form I create. I would hate to have to add that script
reference every time I create a form and would rather have it live in a globally applied script file.

Solutions

There are two solutions.

Solution 1: Create your own process template that includes the script tag in the form configuration

  1. Create a new process using the a built-in template (e.g. SIMPLE_REQUEST).

  2. On the Web References tab in the Form configuration panel, add your Javascript reference.

  3. Save then export the process XPDL to \wfgen\App_Data\Templates\Processes\En\MyProcessTemplates\MY_SIMPLE_REQUESTv1.xml.

You can now start to build a new process with your custom MY_SIMPLE_REQUEST process (in English language), which includes your custom JavaScript reference.

Solution 2: Update the default form HTML template with your JavaScript reference

  1. Open the \wfgen\App_Data\Templates\Forms\En\Default\Default.txt file in a text editor.

  2. Add your JavaScript reference in the HEAD tag.

  3. Save the Default.txt file.

Now, whenever you create a new process (in English language) without being based on process template, the form will include your JavaScript reference.

Important: For solution 2, WorkflowGen updates may overwrite your modified template files, so you should manually update the corresponding templates.