Type identifier:
data:expressionCategory: Data Operations
Evaluates a mathematical or logical expression with variables. Supports arithmetic, string manipulation, date/time operations, similarity functions, and array operations. Use this node for calculations, transformations, and complex data logic.
Handle | Data Type | Required | Description |
|---|---|---|---|
| Varies | Varies | Dynamic handles for each variable |
Input handles are dynamically generated based on the variables configuration. Each variable creates a corresponding input handle using the variable's name as the handle ID.
Notes:
[a-zA-Z0-9_] patternHandle | Data Type | Description |
|---|---|---|
| Varies | The result of the expression |
|
| Triggered on evaluation error |
resultresult schema configurationNotes:
result schema when the schema is coercibleduration, empty object schemas, and arrays of empty object schemas) keep the raw evaluated valueProperty | Type | Required | Default | Description |
|---|---|---|---|---|
|
| Yes |
| Display label for the node |
|
| No |
| Selects the expression language (see below) |
| Array of variable definitions | Yes |
| Input variable definitions |
| Object | Yes | Number type | Result type definition |
|
| Yes |
| The expression to evaluate |
variablesNotes:
name must be alphanumeric with underscoresname is used in the expression and as handle IDexpressionstringNotes:
expression mode (default), uses expr-eval syntaxjs mode, uses standard JavaScript evaluated inside a secure sandbox (see JavaScript Mode)When mode is set to "js", the expression is evaluated as a standard JavaScript expression inside an isolated sandbox.
variables are exposed as global identifiers using their name.dateParse, format, addDuration, cosineSimilarity, jsonParse, or levenshtein) are available as global functions.Temporal global provides the deterministic date/time API described below.The following static APIs are available:
Type | Static methods |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
The following instance APIs are available:
Type | Methods |
|---|---|
|
|
|
|
|
|
|
|
|
|
|
|
Standard scalar properties are available for each supported type. These include date and time fields, ISO calendar fields such as dayOfWeek, weekOfYear, and daysInMonth, timezone fields such as offset and timeZoneId, epochMilliseconds, and duration fields such as hours, sign, and blank. ZonedDateTime.epochSeconds is also available as a convenience.
from, with, arithmetic, difference, rounding, conversion, and string formatting methods accept their standard Temporal string, field object, and options object forms unless listed under Temporal Limitations.
const date = Temporal.PlainDate.from("2024-03-15");
const delivery = date.toZonedDateTime({
timeZone: "Australia/Melbourne",
plainTime: "14:30",
});
delivery.add({ days: 2 }).toInstant();Temporal.PlainYearMonth and Temporal.PlainMonthDay are not supported result types. Their constructors and conversion methods are not available.new Temporal.Instant(...) are not available. Use static from methods.epochNanoseconds and Temporal.Instant.fromEpochNanoseconds are not available. Use epochMilliseconds and fromEpochMilliseconds.toLocaleString is not available.toJSON is not available.valueOf() returns an ISO 8601 string. Native Temporal valueOf() throws instead.Instant.until, Instant.since, ZonedDateTime.until, or ZonedDateTime.since is called without options, the default largestUnit is "hour". Pass an options object to select another unit.Temporal.add(...) is not a Temporal API and is not exposed. Call instant.add(...), date.add(...), or another instance method.Each JavaScript evaluation is constrained to:
Limit | Value | Effect on the expression |
|---|---|---|
Wall-clock budget | 2.5 seconds | Long-running or infinite loops are interrupted and rejected |
Heap memory | 16 MiB | Allocations beyond this cap throw "out of memory" |
Native stack | 1 MiB | Deep or unbounded recursion throws a stack overflow |
When a limit is exceeded the node triggers the error handle with a DATA_EXPRESSION_EVALUATION_ERROR whose message describes the failure mode (such as interrupt, out of memory, or stack overflow).
{
"type": "data:expression",
"data": {
"label": "JS - Total With Tax",
"mode": "js",
"variables": [
{ "name": "price", "type": "number" },
{ "name": "taxRate", "type": "number" }
],
"result": { "name": "total", "type": "number" },
"expression": "price * (1 + taxRate)"
}
}Function | Description | Example |
|---|---|---|
| Basic arithmetic |
|
| Modulo |
|
| Power |
|
| Absolute value |
|
| Round up |
|
| Round down |
|
| Round |
|
| Minimum |
|
| Maximum |
|
| Square root |
|
| Natural log |
|
Function | Description | Example |
|---|---|---|
| String length |
|
| Concatenate |
|
| Substring |
|
| Split string |
|
| Remove whitespace |
|
| Contains check |
|
| Prefix check |
|
| Replace first |
|
| Replace all |
|
| Normalise |
|
Function | Description | Example |
|---|---|---|
| Jaccard similarity |
|
| Edit distance |
|
| LCS |
|
levenshtein and longestCommonSubstring accept inputs of at most 2,500 characters each and throw an error for longer strings.
Function | Description | Example |
|---|---|---|
| Current timestamp |
|
| Parse date string (with natural-language fallback) |
|
| Add duration |
|
| Format date |
|
| Round date |
|
Duration units: years, months, weeks, days, hours, minutes, seconds, milliseconds
dateParse(...) first attempts strict Temporal parsing and then falls back to natural-language parsing for phrases such as "1 week from now". When timeZone is provided, the parsed value is normalised to that timezone and returned as a zoned date-time value.
format(...) accepts an optional timeZone argument. When provided, the input is formatted using that timezone's wall-clock time, which is useful for DST-aware display such as format(appointmentUtc, "hh:mm aaa cccc do MMMM, yyyy", "Australia/Melbourne").
Function | Description | Example |
|---|---|---|
| Array length |
|
| Subarray |
|
| Contains |
|
| Flatten nested |
|
| Sort array |
|
Function | Description | Example |
|---|---|---|
| Cosine similarity |
|
| Euclidean distance |
|
| Manhattan distance |
|
| Hamming distance |
|
Function | Description | Example |
|---|---|---|
| Parse JSON |
|
| Stringify |
|
| Dynamic lookup |
|
| Encode base64 |
|
| Decode base64 |
|
Example with dynamic keys:
get(get(get(get(get(jsonParse(result), "calendars"), calendarId), "busy"), 0), "start")
Operator | Description |
|---|---|
| Equality |
| Comparison |
| Logical |
| Conditional |
result schema when supportedScenario | Behaviour |
|---|---|
Undeclared variable referenced | Triggers |
Variable not connected | Triggers |
Required variable undefined | Error during evaluation |
Expression syntax error | Exception thrown |
Runtime evaluation error | Exception with details |
Result fails schema validation | Exception with details |
{
"type": "data:expression",
"data": {
"label": "Calculate Total",
"variables": [
{ "name": "price", "type": "number" },
{ "name": "quantity", "type": "number" }
],
"result": { "name": "total", "type": "number" },
"expression": "price * quantity"
}
}{
"type": "data:expression",
"data": {
"label": "Check Similarity",
"variables": [
{ "name": "input", "type": "string" },
{ "name": "reference", "type": "string" }
],
"result": { "name": "similarity", "type": "number" },
"expression": "levenshtein(input, reference, true)"
}
}{
"type": "data:expression",
"data": {
"label": "Add 7 Days",
"variables": [{ "name": "startDate", "type": "date" }],
"result": { "name": "endDate", "type": "date" },
"expression": "addDuration(startDate, 7, 'days')"
}
}{
"type": "data:expression",
"data": {
"label": "Parse Date String",
"variables": [{ "name": "startedAt", "type": "string" }],
"result": { "name": "parsedDate", "type": "date", "includeTime": true },
"expression": "dateParse(startedAt)"
}
}{
"type": "data:expression",
"data": {
"label": "Parse Date String In Timezone",
"variables": [
{ "name": "startedAt", "type": "string" },
{ "name": "timeZone", "type": "string" }
],
"result": { "name": "parsedDate", "type": "date", "includeTime": true },
"expression": "dateParse(startedAt, timeZone)"
}
}{
"type": "data:expression",
"data": {
"label": "Natural Language Date",
"variables": [{ "name": "startedAt", "type": "string" }],
"result": { "name": "parsedDate", "type": "date", "includeTime": true },
"expression": "dateParse(startedAt)"
}
}Example input value for startedAt: "1 week from now"
{
"type": "data:expression",
"data": {
"label": "Discount Price",
"variables": [
{ "name": "price", "type": "number" },
{ "name": "isPremium", "type": "boolean" }
],
"result": { "name": "finalPrice", "type": "number" },
"expression": "isPremium ? price * 0.8 : price"
}
}