Edit Custom JavaScript in an External Editor
You can view and edit the custom JavaScript for a form within Form Studio, using the built-in Script Editor, or using an external text editor, such as Notepad++.
By default , Form Studio uses its built-in Script Editor to edit the Script file containing your custom JavaScript functions. However, you can choose to edit the file in an external editor, such as Notepad++, if you prefer. You can edit the Script file from the Properties Pane or Project Explorer within Form Studio or you can open the file directly within an external editor itself, in the standard manner for your chosen editor.
The name of the current editor is displayed on the Status Bar at the bottom of the Form Studio window.
- You can only edit the Script file in one editor at once, you can't edit it in both the built-in Script Editor and an external editor at the same time.
By default, a form's custom JavaScript file can be found in the following location:
C:\Users\<user name>\Documents\NDL Software\Form Studio\Projects\<project name>\CustomScripts
and will have a name looking something like this:
a1b2a1b2-1111-aaaa-2222-a1b2a1b2a1b2_custom.js
When you open a project in Form Studio, a copy of each form's Script file is made in the same folder as the Script files. These copies has the same name as the original files with _copy appended to the end of the file name, e.g.:
a1b2a1b2-1111-aaaa-2222-a1b2a1b2a1b2_custom_copy.js
When you edit a Script file from within Form Studio, whether you use the built-in Script Editor or an external editor, it is the file copy which is edited. The original file is then overwritten by the copy when the project is saved in Form Studio. The copy is deleted when you close the project. This means that if you close the project without saving changes, you will lose your Script changes because the edited copy will be deleted without overwriting the original file first.

To open a Script file from the Project Explorer Pane, expand the tree below the name of your form and click on the Script node. This will open the Script file in the current editor.
If you want to use a different editor, right-click on the Script node to display the following menu:
This menu lists the available editors allowing you to choose the editor you want to use. If you choose an external editor, the editor will load and open the Script file within it. If you want to edit the Script file within Forms Studio, choose FX Editor, in which case the Script file will display in the Form Design workspace.
The Open action at the top of this menu will automatically use the current editor to load the Script file for the current form. The icon to the left of the action shows you the current editor, so in the image above the current editor is Notepad++.
The name of the current editor is displayed on the Status Bar at the bottom of the Form Studio window.
- If you don't see your preferred editor listed on the menu, try opening a JavaScript file in your chosen editor outside Form Studio. To use the custom JavaScript file from your project see Edit your JavaScript directly in an external editor below for details of where to find the file. Right-click on the file in Windows File Explorer and choose Open with from the menu displayed (ignore any Edit with ... options). Choose the required editor from the sub-menu, or if the editor you want isn't listed, click on Choose another app to find the editor you want. Once the editor has loaded and opened the JavaScript file close the file and close the editor. Reload Form Studio and right-click on the Script node again and your chosen editor should now appear on the context-sensitive menu displayed.
Within the editor, you can edit the contents of the Script file in the editor's standard manner.
Remember, if you make any changes to the Script file in an external editor, you will need to save the file within your editor and then save the project within Form Studio in order for the changes to be incorporated into the project.

In the Properties Pane, the Script file, for the current form, will automatically be opened for editing when you choose to create or edit a JavaScript function, under either the (Events) or
(Rules) tabs.
The current editor will load and then open the Script file.
Within the editor, you can edit the contents of the Script file in the editor's standard manner.
Remember, if you make any changes to the Script file in an external editor, you will need to save the file within your editor and then save the project within Form Studio in order for the changes to be incorporated into the project.

In addition to opening a Script file from within Form Studio, you can also open and edit the file directly within an external editor.
If the project is not open in Form Studio, you can edit the original Script file itself. When you have finished save the file, if you want to keep any changes you have made.
On the other hand, if the project is open in Form Studio at the same time, you should edit the copy, save your changes in the editor and then save your project in Form Studio.
Within the external editor, you can edit the contents of the Script file in the editor's standard manner.
If you are editing the Script file in an external editor and you want to make changes to an Element's Event or Rules properties within Form Studio, we recommend you close the file (saving any changes) in the external editor before you make the changes in the Studio. If the changes result in the Studio opening the Script file, it will be opened using the current editor.
Likewise, if you are editing the Script file in an external editor and you want to change to view it within Form Studio, close down the external editor, saving any changes if necessary, before you open the file in the Studio.
If you change the editor you are using to edit the Script file, the new editor will become the current editor and will be used the next time you edit the file, if you don't specify a different editor. When you save your project, the name of the current editor is saved along with any changes and so will be retained when you close your project. If you don't save your project before closing it, the name of the current editor will revert to that in use at the time of the last save or when the project was opened. Each project stores its own current editor value.
See also:
Customise Forms with JavaScript
Advanced Scripting for JavaScript Developers