Documentation Help

Script Editor

The Script Editor is a tool within Helix allowing you to edit and configure HelixScripts. It uses a text editor akin to Visual Studio Code, aiming to make a simple and intuitive interface for editing scripts.

Opening the Script Editor

To open the Script Editor, navigate to the Admin menu and select Script Editor. This will open the editor in a new Helix tab. The editor behaves in the same way as any other tab (e.g. incident details or resource list), and can be repositioned, dragged and dropped or closed as needed.

Only one instance of the Script Editor can be open at a time. If you attempt to open the Script Editor while it is already open, the existing tab will be focused instead.

Script Editor Interface

The Script Editor interface is divided into two sections:

  • Script List: A list of all scripts available in your Helix organisation. This list is sorted first by activity (active scripts are shown first), then by modification date (newest first).

  • Script Editor: The main editing area where you can view and edit the selected script. By default, no script is selected when you first open the Script Editor.

When performing update actions (e.g. saving or deleting a script), the Script Editor will enter a read-only state until the action is complete. This is to prevent accidental changes to the script while it is being saved or deleted.

All feedback from the interface appears in the form of , which appear in the bottom right of the Helix screen. Green usually indicates success, while red indicates an error and orange a user error (e.g. attempting to delete a script without the correct permissions or saving an invalid script).

Creating a Script

To create a script, click the + icon in the top right of the Script List. This will prompt you to name your script.

Scripts can be named anything you like, but they must be valid file names and end in .yml. Two scripts cannot share the same name - if you try to create a script with the same name as an existing script, you will instead open the existing script for editing.

Editing, Validating, and Saving Scripts

The Script Editor provides syntax highlighting and validation for HelixScripts. This includes tab formatting, advanced text editing features and find & replace with regular expression support.

To validate a script, click the Validate button in the top right of the Script Editor. This will check the script for errors without saving it. If the script is valid, a green status message will appear in the bottom right of the Helix screen. Note that validation does not guarantee a script will execute successfully, but rather confirms that the correct parameters have been provided to each action and the file is formatted correctly for Helix's business rule engine.

To save a script, click the Save Changes button in the top right of the Script Editor. This will save the script to the Helix server. Scripts are validated before saving, and if the script is invalid, a red status message will appear in the bottom right of the Helix screen and the script will not be saved.

Activating and Deactivating Scripts

To activate a script, click the Activate button in the top right of the Script Editor. This will make the script available for execution within Helix. Activated scripts are shown at the top of the Script List with a green dot next to their name.

An activated script is considered for execution when its trigger event is fired. If the script is valid and the trigger event is fired, the script will execute. See Trigger Events for a list of first-party events that can be used to trigger scripts.

When working with scripts, it is recommended to follow these best practices:

Use Descriptive Names

When naming your scripts, use descriptive names that clearly indicate what the script does. This will make it easier to find and manage your scripts in the future. When developing scripts for a specific purpose, consider using a naming convention that includes the purpose of the script, e.g. incident-escalate-to-supervisor.

Helix recommends prefixing each script with the object type it is designed to work with, e.g. incident- for incident scripts, call- for call scripts, etc.

Use Comments

Comments are a great way to document your scripts and explain what each section does. Use comments liberally to provide context and explanations for your scripts. In YAML, comments are denoted by the # character.

# In yaml, this is a comment id: 'incident-escalate-to-supervisor' trigger: - event: 'helix:incident_created' condition: - 'incident.priority === 1' - 'incident.tagset ~= "firearms"'

Test Your Scripts

Before activating your scripts, be sure to test them in a development or staging environment. This will help you catch any errors or issues before they cause problems in production.

Never modify a script in a production environment unless you are confident it will not cause issues. If you need to make changes to a script in production, consider deactivating the script first, making the changes, then reactivating the script.

Regularly Review and Update Scripts

A "less is more" approach is often beneficial when working with scripts. Regularly review your scripts to ensure they are still necessary and functioning as expected. Remove any scripts that are no longer needed or are causing issues.

If two scripts cover the same business logic or are conflicting, consider merging them into a single script. This will reduce complexity and make it easier to manage your scripts.

Stay consistent

When developing scripts, try to stay consistent with your naming conventions, formatting, and commenting style. This is especially important when working in a team environment, as it makes it easier for others to understand and work with your scripts.

Last modified: 27 December 2024