# Form designer: How to create global JavaScript functions?

**URL:** <https://discuss.workflowgen.com/t/form-designer-how-to-create-global-javascript-functions/254>\
**Category:** Form Designer\
**Created:** [September 11, 2013, 12:34am UTC](https://discuss.workflowgen.com/t/form-designer-how-to-create-global-javascript-functions/254 "2013-09-11T00:34:54Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![wfg-admin](https://yyz2.discourse-cdn.com/flex030/user_avatar/discuss.workflowgen.com/wfg-admin/32/714_2.png) [@wfg-admin](https://discuss.workflowgen.com/u/wfg-admin)\
**Post date:** [September 11, 2013, 12:34am UTC](https://discuss.workflowgen.com/t/form-designer-how-to-create-global-javascript-functions/254/1 "2013-09-11T00:34:54Z")

</div>

### 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.
