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
Scripts fall into two categories:
- Actor scripts — perform side effects on objects. Triggered via
POST, run automatically on create/update, or invoked manually from the UI. - Producer scripts — return a list of results without modifying any object. Always invoked on demand via
GET. See Sources for details.
| Type | JSON value | Category | Description |
|---|---|---|---|
| JavaScript | javascript | Actor or Producer | Run a JavaScript function, inline or from a file. |
| Statement | statement | Actor | Declaratively create or update objects. |
| Consumer Gateway | consumerGateway | Actor | Call an external service (e.g. send an email). |
| Function Gateway | functionGateway | Actor | Call an enrichment function and write the results back to the object. |
| Producer Gateway | producerGateway | Producer | Query an external source and return a list of results. |
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, producerGateway. |
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"]
| Value | UI label | When it runs |
|---|---|---|
MANUAL | "Manual Action" | The script appears as a button in the UI. The user clicks it to run it. |
CREATE | — | Runs automatically when the object is first created. |
UPDATE | — | Runs automatically every time the object is saved. |
The UI displays manual scripts as "Manual Action", but the enum value in JSON is "MANUAL" — not "MANUAL_ACTION". Using "MANUAL_ACTION" is an invalid value and will cause the metadata endpoint to fail for the entire tenant (see warning below).
An unrecognised trigger value causes a deserialization error when the platform loads the class definition. This failure affects the metadata endpoint for the entire tenant, not just the class containing the error. Always use one of the three documented values: MANUAL, CREATE, UPDATE.