Using the script editor
- Opening the script editor
- Elements of the script editor
- See also
When editing dashboards or other views, the script editor lets you add custom functionality.
2. Opening the script editor
You open a script for editing by going to the Properties window for a dashboard, or some content that has been added to the canvas.
Scroll down to the ACTIONS section and expand the action you want to handle. Click the plus sign to add a new script or select an existing script.
The Script Editor window opens and is docked along the bottom of the canvas.
3. Elements of the script editor
The script editor consists of these main elements:
- Script Explorer panel
- Editor area
The toolbar in the script editor lets you:
- Build the script to check if it is valid
- Go to a specific line number in the script
- Undo or redo your changes in the editor
- Show or hide the Script Explorer panel
- See the name of your script
- See what line number and column you are at in the editor (i.e., cursor position)
3.2. Script explorer
To show or hide the Script Explorer panel, click the Script Explorer button in the editor toolbar.
The Script Explorer panel has two parts: an Object Explorer and a Type Explorer.
The Object Explorer lists all of the currently-available objects on your dashboard (in alphabetical order). These objects exist on the dashboard or application and can be manipulated by the statements you write in the editor.
Expand the triangles on the left to see what properties and methods are available on each object.
The Type Explorer lists all of the data types that are supported for scripting (similar to an API reference).
The editor is the large text area where you compose and edit your script.
4.1. Build script
Click Build in the editor toolbar to build your script and check for syntax errors.
If an error is detected, click the error link to move the editor cursor to the location of the error.
If there are no errors, you'll see a message indicating the script is valid.
4.2. Go to line number
To move the cursor to a specific line number in your script, click Line in the editor toolbar.
Enter the line number and then click Go.
4.3. Undo and redo
Use the Undo and Redo buttons to revert or re-apply your actions in the editor area.
List matching properties, etc - Type ‘chart1’ followed by the period character in the editor. Then press CTRL+SPACE to enter auto-complete mode. Type a couple of characters and you'll see the auto-complete popup listing properties and methods that match, along with the corresponding API description. Use the arrow keys to cycle through the available choices, or click on an item with your mouse. When you've found the item you want to insert into your script, press ENTER or double-click the item.
Function/method parameters - In the case of a method or function, once you've added it to your script by pressing ENTER, type the open bracket '(' to see the function/method signature. The first required parameter will be underlined. As you type each parameter, the popup will underline the next parameter that is required.
All available types - While on a new line, press CTRL+SPACE to see the auto-complete popup showing all available types.
The following table describes what the icons in the auto-complete popup means:
4.5. Highlight instances of current object for renaming
To rename all instances of an object, move your cursor over one of the instances or click on it.
Press CTRL+. to select all instances of the object, and then type the new name.
4.6. Jump to object declaration
While your cursor is over an object, press ALT+. to highlight the object where it is defined (i.e., its var statement).
4.7. Show documentation for current object
While your cursor is over an object, press CTRL+o to display the documentation for the object in a popup.
Press CTRL+/ to comment the current line (where the cursor is located) or multiple selected lines in the editor.
If the current line or selected lines are already commented, this key sequence will uncomment the line or selected lines.
On a Mac computer, using CTRL+/ or CMD+/ will work the same to comment or uncomment code.