Portal Community

Properties

PropertyRequiredDescription
ScriptRequiredJavaScript code to execute. Write full function-body code — you have access to the context object. Use return to set the output value. If no return is present, the last expression's value is used.
TimeoutOptionalInteger. Maximum execution time in milliseconds. If the script runs longer than this value, it is terminated and the error port fires with errorCode: "timeout". If omitted, the platform's default timeout applies.
SandboxModeOptionalBoolean. Default true. Restricts available globals to safe JavaScript built-ins only. Set false only in trusted, self-hosted deployments. See the security model on the Overview page.

The context Object

Inside every Function script, the context object is automatically injected. It provides read access to all workflow data:

context.input

The data passed into the current node from the preceding node's success port.

// Access the full input object
const inputData = context.input;

// Access a specific field from upstream output
const productName = context.input.product_name;
const itemCount = context.input.items.length;

context.vars

All workflow-level variables set by VariableAssignment nodes earlier in the flow.

const userId = context.vars.user_id;
const orderTotal = context.vars.order_total;
const itemsList = context.vars.items_array; // can be any type

context.nodes

Output data from previously executed nodes in this workflow run, keyed by node name or node ID.

// Access output from a node named "GetCustomer"
const customerEmail = context.nodes.GetCustomer.email;

// Access output from a node named "FetchPrices"
const prices = context.nodes.FetchPrices.items;

context.workflow

Metadata about the current workflow run.

PropertyTypeDescription
context.workflow.runIdstringUnique ID for the current workflow run instance.
context.workflow.workflowIdstringID of the workflow definition being executed.
context.workflow.workflowNamestringHuman-readable name of the workflow.
context.workflow.startedAtstringISO timestamp when the workflow run started.
context.workflow.triggeredBystringWhat triggered the workflow: "manual", "schedule", "webhook", etc.

context.env

Environment-level configuration values set by administrators (read-only). Only available when SandboxMode=false or when the platform explicitly exposes specific keys to sandboxed scripts.

Return Value Behaviour

The return value of the Function script becomes the output data on the success port.

Script PatternResult
return { key: "value" };Object { key: "value" } becomes the success output data field.
return [1, 2, 3];Array [1, 2, 3] becomes the success output data field.
return "hello";String "hello" becomes the success output data field.
return null;data is null.
No return statementThe value of the last expression is used. If the last statement is a declaration with no value, data is undefined.
throw new Error("msg");Routes to error port with errorCode: "script_error" and the error message.
Always use explicit return. Relying on the last-expression behaviour can produce unexpected results when code editors reformat scripts. Always use an explicit return statement for clarity and predictability.
Return values must be JSON-serialisable. The return value is serialised to JSON before being passed to downstream nodes. Functions, Dates, undefined, and circular references will either be omitted or cause serialisation errors. Convert Dates to ISO strings (date.toISOString()) before returning.