Eval Step
The Eval step runs JavaScript inside the flow. You map values in as params, write code, and the value the code evaluates to becomes the step’s result. The runtime is small and embedded — not Node.js. There is no module system, no console, no timers and no network access. Everything the code works with must arrive through params.The contract
Three rules cover nearly every mistake people make with this step:- Each params key becomes a global variable. A param named
ticketsis used in the code astickets, notparams.ticketsand notinput.tickets. - The result is the value of the last expression. There is no output variable to assign.
- You cannot
returnat the top level. A barereturnis a syntax error. To usereturn, wrap the code in a function and call it immediately.
Configuration
The editor has a General tab (step name and ID) and a Code tab holding four sub-tabs:
Run Test executes the code against the Lookup data using the same engine the flow uses.
string
required
The JavaScript to evaluate.
JSON object
Variables to expose to the code.
{"tickets": "$.GET_TICKETS.data", "threshold": 20} gives the code a tickets variable and a threshold variable. Values may be literals or JSONPath.Examples
Every example below was run through the engine the step uses; the outputs are what it returned.Reshape a list
Paramstickets = [{"ref":"T-104","team":"support","minutes":45,"resolved":true}, {"ref":"T-105","team":"support","minutes":12,"resolved":false}, {"ref":"T-106","team":"onboarding","minutes":30,"resolved":true}]:
Aggregate with a wrapped function
Statements need a function around them, and the call must be the last expression.Guard against a param that resolved to nothing
A JSONPath that matches nothing resolves to an empty array — notnull and not undefined — so check for that shape before working on it.
Params
{ "status": "no_data", "slow": [] }. With two tickets of 45 and 12 minutes: { "status": "ok", "slow": ["T-104"] }.
Dates and modern syntax
const, let, arrow functions, template literals, classes and spread all work.
Params
created_at = "2026-08-27T09:15:00Z" and name = " Dana Reyes ":
What the runtime does not have
Built-ins that are present includeJSON, Math, Date, RegExp, Object, Array and String, with the common newer methods such as Object.entries and Array.prototype.includes. The editor summarises the level of support as core ES5 plus part of ES6.
Referencing the result
The value is stored flat under the step’s ID. If the step ID iseval_1 and the code returned an object:
$.eval_1 is that value. There is no .output or .result wrapper.
Troubleshooting
SyntaxError: Illegal return statement
SyntaxError: Illegal return statement
The code has a
return outside a function. Wrap the body in (function () { … })().ReferenceError: <name> is not defined
ReferenceError: <name> is not defined
Either the variable is a params key that was never added on the Params sub-tab, or it is something the runtime does not provide —
require, console, setTimeout, fetch, process.The result is an empty object
The result is an empty object
An
async function was called, or a Promise was the last expression. Neither ever settles here. Rewrite the code synchronously.A variable holds an empty array instead of the data
A variable holds an empty array instead of the data
The JSONPath in Mapped Params matched nothing. Check the path against the Lookup tab, remembering that a step’s data is keyed by its step ID.
The run never finishes
The run never finishes
A loop is not terminating. Nothing times the code out, so the guard has to be in the code.
Editing a flow changes its draft. Test there, then Publish to make the change take effect.
Next Steps
Map Step
Reshape data without writing code
Variable Mapping
JSONPath reference for Mapped Params
Condition Step
Branch on what the code returned
Functions Step
Built-in operations for common tasks