The condition step determines the next step in the action by evaluating a JavaScript expression. Return true to execute the left-hand side step, or false to execute the right-hand side step.
return {{data.length}} >0;
Built-in variables
The following built-in variables are available:
// result of the previous stepreturn {{data}};// error response of the previous stepreturn {{error}};// incoming action params, passed in by components,// the Execution/Loop action steps or when calling the action from the codereturn {{params}};// the response of the request, if the Code step follows an HTTP API stepreturn {{res}};
While {{data}} and {{error}} are specific to a particular step, {{params}} is available in all steps.
Using variables:
// use `{{data.<key>}}` to access a specific keyreturn {{data.name}};// to access the first element of the arrayreturn {{data[0]}};// to access the `name` key of the first elementreturn {{data[0].name}};
Optional chaining
If, at some point, variable's value is null or undefined, an optional chaining operator ?. can be used to access a specific key.
For example:
// if `data` is `null` or `undefined`, `name` will not produce an errorreturn {{data?.name}};// if `data` is `null` or `undefined`, `name` will not produce an errorreturn {{data?.[0]?.name}};
Examples
Execute the true step if the data array has some items:
return {{data.length}} >0;
Execute the true step if the component's value is set: