Expressions and code
Use convenience methods in Duaer expressions
In a Duaer expression, use $json for the current item, $("Node name") for an earlier node, and $now and $if() for time and conditions.
The current item and earlier nodes
- $json is the current item. $json.city is the city field.
- $binary is the file on the current item.
- $("Node name").first() is that node’s first item. last() is the last. all() is every item.
- $("Node name").item is the item linked to the current output. Linking is in How items stay linked through a run.
- $itemIndex is this item’s position in the batch, starting at 0. $runIndex is how many times this node has run, also from 0.
- $prevNode.name, $prevNode.outputIndex, and $prevNode.runIndex describe the node immediately before this one.
Time, conditions, and empty values
- $now is the current date and time. $today is today. Format with $now.toFormat("yyyy-MM-dd"). Details are in Work with dates using Luxon in Duaer.
- $if(condition, valueIfTrue, valueIfFalse) picks a value. The ternary condition ? a : b works too.
- $ifEmpty(value, defaultValue) returns the default when the value is undefined, null, an empty string, an empty array, or an empty object.
{{ $ifEmpty($json.city, "unknown") }}This execution, this workflow, and variables
- $execution.id is this execution’s id. $execution.mode says whether the run was manual or started by a live trigger. $execution.customData reads and writes custom execution data.
- $workflow.id, $workflow.name, and $workflow.active are this workflow’s id, name, and whether it is active.
- $vars.key reads Define custom variables in Duaer.
Questions
Which values does $ifEmpty treat as empty in Duaer?
In a Duaer expression, $ifEmpty(value, default) returns the default for undefined, null, an empty string, an empty array, or an object with no fields. Any other value is returned as it is.
How do you format the current time in Duaer?
In a Duaer expression, $now is the current time and $today is today. Write {{ $now.toFormat("yyyy-MM-dd") }}.
In this section
Use built-in methods and variables in Duaer
Duaer's built-in methods and variables for working with data in expressions. The Code node runs plain JavaScript and native Luxon.
ExpressionsTransform data with expressions in Duaer
Use expression transformation functions anywhere expressions are supported in Duaer. When you only reshape fields, prepare them in Edit Fields (Set) first.
DatesWork with dates using Luxon in Duaer
Dates in a Duaer expression are Luxon DateTime values. $now and $today already are. The Code node uses native Luxon—format() and plus(amount, unit) do not carry over unchanged.