Skip to main content

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

TypeJSON valueDescription
JavaScriptjavascriptRun a JavaScript function, inline or from a file.
StatementstatementDeclaratively create or update objects.
Consumer GatewayconsumerGatewayCall an external service (e.g. send an email).
Function GatewayfunctionGatewayCall an enrichment function and write the results back to the object.

Common properties

All script types share these properties:

PropertyTypeDefaultDescription
namestringUnique identifier for this script within the class.
typestringOne of javascript, statement, consumerGateway, functionGateway.
scopeGENERAL | OBJECTOBJECT: applies to a specific class. GENERAL: not tied to a specific object.
triggerMANUAL | CREATE | UPDATE | string[]MANUALWhen the script runs. A single value or an array, e.g. "UPDATE" or ["CREATE", "UPDATE"].
parametersParameter[]Input values passed to the script.
preconditionsstring[]Formula expressions that must all evaluate to true before the script runs.
triggerValuesstring[]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:

PropertyDescription
valueA literal value.
formulaA formula expression evaluated on the current object.
templateA Handlebars template string evaluated on the current object.
templateFilePath 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.