Scripts
Script patterns
Choose between ObjectScript, workflow scriptNode, and playground testing patterns.
Antly supports two main script patterns: object scripts that follow a record and workflow script nodes that run inside a graph.
ObjectScript
Use objects.ObjectScript when the rule belongs to an object record lifecycle. Examples:
- Normalize a field before or after save.
- Copy values into a derived attribute.
- Block invalid combinations with
raise_error_on_failure. - Create related tasks or tickets after a record enters a state.
Keep object scripts local to the object. If the script starts coordinating several teams, approvals, waits, or external services, use a workflow instead.
amount = float(instance.data.get("amount") or 0)
if amount > 10000:
instance.data["approval_required"] = True
instance.data["risk_band"] = "high"
instance.save()Workflow script nodes
Use a workflow scriptNode when the code is one step in a larger process. The workflow gives you trigger data, previous node outputs, decision paths, retries, and logs. Script nodes work well for:
- Preparing data before an action node.
- Translating trigger payloads into a compact object.
- Calling Antly namespaces as part of an approval or task process.
- Returning a value used by later route, decision, or action nodes.
The workflow enum value is scriptNode. See /guides/workflow-studio, /guides/node-reference, and /guides/scripts.
1{
2 "type": "scriptNode",
3 "data": {
4 "label": "Prepare renewal payload",
5 "script": "record = context.get('record')\nreturn {'customer_id': record['id'], 'renewal_total': record['data'].get('total')}"
6 }
7}Playground workflow
Use the playground before publishing:
- Pick a real record, task, or ticket with representative data.
- Run the script with non-destructive reads first.
- Add writes only after the result shape is correct.
- Test failure behavior with
raise_error_on_failureenabled and disabled. - Publish after the script output and workflow logs match the expected process.
For API-level operations used by scripts, read /reference/crud-operations and /reference/errors.