Scripts Overview
Scripts define actions that can be triggered on objects. They can run automatically when an object is created or updated, or they can be triggered manually by the user.
Script types
| Type | JSON value | Description |
|---|---|---|
| JavaScript | javascript | Run a JavaScript function, inline or from a file. |
| Statement | statement | Declaratively create or update objects. |
| Consumer Gateway | consumerGateway | Call an external service (e.g. send an email). |
| Function Gateway | functionGateway | Call an enrichment function and write the results back to the object. |
Common properties
All script types share these properties:
| Property | Type | Default | Description |
|---|---|---|---|
name | string | — | Unique identifier for this script within the class. |
type | string | — | One of javascript, statement, consumerGateway, functionGateway. |
scope | GENERAL | OBJECT | — | OBJECT: applies to a specific class. GENERAL: not tied to a specific object. |
trigger | MANUAL | CREATE | UPDATE | string[] | MANUAL | When the script runs. A single value or an array, e.g. "UPDATE" or ["CREATE", "UPDATE"]. |
parameters | Parameter[] | — | Input values passed to the script. |
preconditions | string[] | — | Formula expressions that must all evaluate to true before the script runs. |
triggerValues | string[] | — | For UPDATE trigger: only run when a watched field changes to one of these values (e.g. a specific status). |
Parameters
Parameters pass values into a script. Each parameter has a name and exactly one value source:
| Property | Description |
|---|---|
value | A literal value. |
formula | A formula expression evaluated on the current object. |
template | A Handlebars template string evaluated on the current object. |
templateFile | Path to a template file in the repository (without extension). |
{
"name": "email",
"dataType": "EMAIL",
"formula": "emailAddress"
}
{
"name": "subject",
"dataType": "TEXT",
"value": "You have been invited"
}
{
"name": "message",
"dataType": "TEXT",
"templateFile": "templates/invitationMailText"
}
Preconditions
Preconditions are formula expressions. The script only runs if all preconditions evaluate to true. They are evaluated on the current object before the script executes.
{
"preconditions": ["emailAddress != null", "activeDate != null"]
}
Triggers
The trigger property accepts a single string or an array of strings:
"trigger": "UPDATE"
"trigger": ["CREATE", "UPDATE"]
MANUAL— the script appears as a button in the UI. The user clicks it to run it.CREATE— the script runs automatically when the object is first created.UPDATE— the script runs automatically every time the object is saved.