Portal Community

Output Ports

PortDescription
successScript completed without error. Output contains data (the return value of the script) plus execution metadata.
errorScript threw an unhandled exception, the timeout was exceeded, or a syntax error was detected at parse time. Includes errorCode, message, and stack.

Accessing Input Data in Scripts

All upstream workflow data is available via the context object. Here are the most common access patterns:

Reading the upstream node's output

// The data from the node immediately before this Function node
const payload = context.input;
const productId = context.input.product_id;
const items = context.input.items; // works if upstream returned an array

Reading workflow variables

// Variables set by VariableAssignment nodes
const customerId = context.vars.customer_id;
const pricingTier = context.vars.pricing_tier;
const cart = context.vars.cart_items; // arrays and objects are fully supported

Reading outputs from named nodes

// Access the success output of a node named "FetchOrder"
const order = context.nodes.FetchOrder;
const orderTotal = context.nodes.FetchOrder.total;

// Access nested data
const firstItem = context.nodes.FetchOrder.items[0];

Reading workflow run metadata

const runId = context.workflow.runId;
const startedAt = context.workflow.startedAt;
const trigger = context.workflow.triggeredBy;

success Port Output Schema

FieldTypeDescription
dataanyThe return value of the script. Can be any JSON-serialisable value: object, array, string, number, boolean, or null.
executionTimeMsintegerTime taken to execute the script in milliseconds.
statusstringAlways "success" on this port.
// If the script returned: { total: 149.97, discounted: 127.47, savings: 22.50 }
{
  "data": {
    "total": 149.97,
    "discounted": 127.47,
    "savings": 22.50
  },
  "executionTimeMs": 3,
  "status": "success"
}

In downstream nodes, reference the script output as {{ nodes.FunctionNodeName.data.total }} or {{ nodes.FunctionNodeName.data }} for the full returned object.

error Port Output Schema

FieldTypeDescription
statusstringAlways "error".
errorCodestringOne of: script_error (runtime exception), timeout (execution exceeded Timeout), syntax_error (script could not be parsed).
messagestringThe error message — either from the thrown Error object or the timeout/syntax description.
stackstringStack trace for script_error. Empty for timeout and syntax_error.
executionTimeMsintegerTime elapsed before the error occurred.
// Runtime error example:
{
  "status": "error",
  "errorCode": "script_error",
  "message": "Cannot read properties of undefined (reading 'price')",
  "stack": "TypeError: Cannot read properties of undefined (reading 'price')\n    at <anonymous>:3:42",
  "executionTimeMs": 1
}

// Timeout example:
{
  "status": "error",
  "errorCode": "timeout",
  "message": "Script execution exceeded timeout of 5000ms.",
  "stack": "",
  "executionTimeMs": 5001
}
Defensive coding tip: Always guard against null or undefined values when accessing context.input or context.nodes fields. Use optional chaining (context.input?.price ?? 0) to prevent TypeError exceptions and ensure the script routes to the success port with a handled default value rather than the error port.