Please ensure Javascript is enabled for purposes of website accessibility
Powered by Zoomin Software. For more details please contactZoomin

AVEVA™ Work Tasks

Script Editor

  • Last UpdatedJun 25, 2024
  • 3 minute read

Script Editor is a custom editor to code in JavaScript.

To work with the Script Editor

  1. In the Enterprise Console, click the Menu button, and then click Forms. The Forms page appears.

  2. Right-click on a form, and then click Design Form (or click on a form, and then click Design). The Forms Designer page appears.

  3. Point to the control, and then click the Properties button. The Properties dialog box appears.

  4. Click the Scripts tab, and then click the Script Editor button for the required property. The Script Editor page appears.

  5. Code the script, and then click Save & Close.

    The script is saved and the Script Editor page is closed.

    Note: If you click Cancel, the Script Editor page is closed. Any changes made to the code since it was last saved, is discarded.

Script Editor Interface

Action Bar

Action bar has commands to edit the script and preview the form.

Menu/Command

Description

Undo

Undo the last change made to the script.

Redo

Redo the last change that was undone.

Revert

Revert to a previously saved script.

Clear All

Clear the code from the editor.

Indent All

Indent the code.

Check Syntax

Validate the code.

Note:

- Use Camel case when coding in JavaScript.

- We recommend to validate the code before saving the script to ensure there are no errors in the code.

Preview

Preview the form. For more information, see Preview Forms.

Device Preview

Preview the form from a device. For more information, see Preview Forms.

XML Structure

The XML Structure displays all the controls that contain XML nodes in the same hierarchy as the form is designed. When you select a node, the default script is inserted in the script editor. If you select the same control as that in which you are coding the script, then the currentValue is displayed. If you select a container control, the default script inserted is control.findByXmlNode("Xml node"). If you select any other control, the default script inserted is control.findByXmlNode("Xml node").value.

APIs

The APIs displays all the Skelta.form.utilities (SFU) APIs. When you select an API, the API is inserted inside the script editor.

Control Structure

The Control Structure displays all the control nodes in the same hierarchy as the form is designed. When you select a node, the default script is inserted in the script editor. If you select the same control as that in which you are coding the script, then the currentValue is displayed. If you select a container control, the default script inserted is control.findById("ID"). If you select any other control, the default script inserted is control.findById("ID").value. If you select the top level root node, the script inserted is control.topLevelForm.

Intellisense

Use intellisene to code scripts in the Scripts Editor . Intellisense in the Script Editor is triggered when you press Ctrl + Space.

  • When you press Ctrl + Space in a new line or when the Script Editor is empty, then a list of all the available global objects appears.

  • When you write control. and press Ctrl + Space, then depending on the control or container that you are scripting for in the script editor, a list of the control or container properties and methods appears. For example:

    • To add scripts in the script editor of a Text control, when you write control. and press Ctrl + Space, a list of the properties and methods applicable only for Text control appears.

    • To add scripts in the script editor of a Base Form container, when you write control. and press Ctrl + Space, a list of the properties and methods applicable only for Base Form container appears.

  • When you write control.findById( , control.findByName(, or control.findByXmlNode( and press Ctrl + Space, then a list of the Ids, names or XML nodes applicable for the control or container appears.

Note:
- The editor must not have any string with ]]> or CDATA, otherwise you will not be able to save the script.
- The script must return a value for all the properties under the Scripts tab of the respective control:
- The script is auto saved every 1 minute.
- To write the scripts for functions, see Best Practices.

In This Topic
Related Links
TitleResults for “How to create a CRG?”Also Available in