Login
Free Sign Up
Docs
/

Data - Expression

Type identifier: data:expression Category: Data Operations

Description

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.

Input Handles

Handle

Data Type

Required

Description

{variableName}

Varies

Varies

Dynamic handles for each variable

Input Handle Details

Variable Handles

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.

  • Type: Defined by each variable's schema configuration
  • Notes:

    • Only variables referenced in the expression need to be connected
    • Unconnected required variables will cause errors
    • Variable names must match [a-zA-Z0-9_] pattern

Output Handles

Handle

Data Type

Description

result

Varies

The result of the expression

error

trigger

Triggered on evaluation error

Output Handle Details

result

  • Type: Defined by the result schema configuration
  • Notes:

    • Result is validated against the configured result schema when the schema is coercible
    • Loosely-typed result schemas (for example: duration, empty object schemas, and arrays of empty object schemas) keep the raw evaluated value

Configuration Options

Property

Type

Required

Default

Description

label

string

Yes

"Data - Expression"

Display label for the node

mode

"expression" | "js"

No

"expression"

Selects the expression language (see below)

variables

Array of variable definitions

Yes

[]

Input variable definitions

result

Object

Yes

Number type

Result type definition

expression

string

Yes

""

The expression to evaluate

Configuration Details

variables

  • Type: Array of variable definitions
  • Notes:

    • Each variable defines an input handle
    • Variable name must be alphanumeric with underscores
    • Variable name is used in the expression and as handle ID

expression

  • Type: string
  • Notes:

    • In expression mode (default), uses expr-eval syntax
    • In js mode, uses standard JavaScript evaluated inside a secure sandbox (see JavaScript Mode)
    • Supports extended functions for dates, strings, and vectors
    • Variables are referenced by their name

JavaScript Mode

When mode is set to "js", the expression is evaluated as a standard JavaScript expression inside an isolated sandbox.

Available Bindings

  • All declared variables are exposed as global identifiers using their name.
  • The same shared helper functions described under Supported Functions (such as dateParse, format, addDuration, cosineSimilarity, jsonParse, or levenshtein) are available as global functions.
  • A Temporal global provides the deterministic date/time API described below.

Temporal API

The following static APIs are available:

Type

Static methods

Temporal.Now

instant, zonedDateTimeISO, plainDateTimeISO, plainDateISO, plainTimeISO, timeZoneId

Temporal.Instant

from, fromEpochMilliseconds, fromEpochSeconds, compare

Temporal.PlainDateTime

from, compare

Temporal.PlainDate

from, compare

Temporal.PlainTime

from, compare

Temporal.ZonedDateTime

from, compare

Temporal.Duration

from, compare

The following instance APIs are available:

Type

Methods

Instant

equals, add, subtract, until, since, round, toZonedDateTimeISO, toString

PlainDateTime

equals, with, withPlainTime, withCalendar, add, subtract, until, since, round, toZonedDateTime, toPlainDate, toPlainTime, toString

PlainDate

equals, with, withCalendar, add, subtract, until, since, toPlainDateTime, toZonedDateTime, toString

PlainTime

equals, with, add, subtract, until, since, round, toString

ZonedDateTime

equals, with, withPlainTime, withCalendar, withTimeZone, add, subtract, until, since, round, startOfDay, getTimeZoneTransition, toInstant, toPlainDateTime, toPlainDate, toPlainTime, toString

Duration

with, add, subtract, negated, abs, round, total, toString

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 Limitations

  • Temporal.PlainYearMonth and Temporal.PlainMonthDay are not supported result types. Their constructors and conversion methods are not available.
  • JavaScript constructors such as 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.
  • When 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 objects use the ISO 8601 calendar in normal Flow data. Calendar conversion methods are exposed for compatibility, but non-ISO Temporal values may not pass the configured date result schema.
  • Temporal.add(...) is not a Temporal API and is not exposed. Call instant.add(...), date.add(...), or another instance method.

Resource Limits

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).

Example

{
  "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)"
  }
}

Supported Functions

Arithmetic

Function

Description

Example

+, -, *, /

Basic arithmetic

a + b * 2

%

Modulo

a % 10

^

Power

2 ^ 3

abs(x)

Absolute value

abs(-5)

ceil(x)

Round up

ceil(4.2)

floor(x)

Round down

floor(4.8)

round(x)

Round

round(4.5)

min(a, b, ...)

Minimum

min(1, 2, 3)

max(a, b, ...)

Maximum

max(1, 2, 3)

sqrt(x)

Square root

sqrt(16)

log(x)

Natural log

log(10)

String Functions

Function

Description

Example

length(s)

String length

length("hello")

concat(a, b)

Concatenate

concat("hello", " world")

slice(s, start, end)

Substring

slice("hello", 0, 2)

split(sep, s)

Split string

split(",", "a,b,c")

trim(s)

Remove whitespace

trim(" hello ")

includes(s, search)

Contains check

includes("hello", "ell")

startsWith(s, prefix)

Prefix check

startsWith("hello", "he")

replace(s, old, new)

Replace first

replace("hello", "l", "x")

replaceAll(s, old, new)

Replace all

replaceAll("hello", "l", "x")

normalizeString(s, lower?, accents?, spaces?)

Normalise

normalizeString("Héllo", true, true)

String Similarity

Function

Description

Example

jaccard(s1, s2, normalize?)

Jaccard similarity

jaccard("hello world", "hello there")

levenshtein(s1, s2, normalize?)

Edit distance

levenshtein("hello", "hallo")

longestCommonSubstring(s1, s2)

LCS

longestCommonSubstring("hello", "jello")

levenshtein and longestCommonSubstring accept inputs of at most 2,500 characters each and throw an error for longer strings.

Date/Time Functions

Function

Description

Example

now()

Current timestamp

now()

dateParse(dateTime, timeZone?)

Parse date string (with natural-language fallback)

dateParse("2026-10-01T12:34:56Z", "America/Vancouver")

addDuration(dt, value, unit)

Add duration

addDuration(date, 5, "days")

format(dt, pattern, timeZone?)

Format date

format(date, "yyyy-MM-dd", "Australia/Melbourne")

round(dt, increment?, unit?, mode?)

Round date

round(date, 1, "hour")

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").

Array Functions

Function

Description

Example

length(arr)

Array length

length([1, 2, 3])

slice(arr, start, end)

Subarray

slice([1,2,3,4], 1, 3)

includes(arr, item)

Contains

includes([1,2,3], 2)

flatten(arr, depth?)

Flatten nested

flatten([[1,2],[3,4]])

sort(fn, arr)

Sort array

sort((a,b) => a-b, [3,1,2])

Vector Functions

Function

Description

Example

cosineSimilarity(v1, v2)

Cosine similarity

cosineSimilarity([1,0], [0,1])

euclideanDistance(v1, v2)

Euclidean distance

euclideanDistance([0,0], [3,4])

manhattanDistance(v1, v2)

Manhattan distance

manhattanDistance([0,0], [3,4])

hammingDistance(v1, v2)

Hamming distance

hammingDistance([1,0,1], [1,1,0])

JSON Functions

Function

Description

Example

jsonParse(s)

Parse JSON

jsonParse('{"a":1}')

jsonSerialize(v, pretty?)

Stringify

jsonSerialize(obj, true)

get(v, key, default?)

Dynamic lookup

get(obj, dynamicKey)

base64encode(s)

Encode base64

base64encode("hello")

base64decode(s)

Decode base64

base64decode("aGVsbG8=")

Example with dynamic keys:

get(get(get(get(get(jsonParse(result), "calendars"), calendarId), "busy"), 0), "start")

Comparison

Operator

Description

==, !=

Equality

<, >, <=, >=

Comparison

and, or, not

Logical

?: (ternary)

Conditional

Behaviour

Execution Flow

  1. Validates all referenced variables are declared
  2. Validates all referenced variables have connected edges
  3. Evaluates the expression with the connected variable values
  4. Validates/coerces result against the configured result schema when supported
  5. Returns result or triggers error

Error Handling

Scenario

Behaviour

Undeclared variable referenced

Triggers error handle

Variable not connected

Triggers error handle

Required variable undefined

Error during evaluation

Expression syntax error

Exception thrown

Runtime evaluation error

Exception with details

Result fails schema validation

Exception with details

Examples

Simple Arithmetic

{
  "type": "data:expression",
  "data": {
    "label": "Calculate Total",
    "variables": [
      { "name": "price", "type": "number" },
      { "name": "quantity", "type": "number" }
    ],
    "result": { "name": "total", "type": "number" },
    "expression": "price * quantity"
  }
}

String Comparison

{
  "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)"
  }
}

Date Calculation

{
  "type": "data:expression",
  "data": {
    "label": "Add 7 Days",
    "variables": [{ "name": "startDate", "type": "date" }],
    "result": { "name": "endDate", "type": "date" },
    "expression": "addDuration(startDate, 7, 'days')"
  }
}

Date From String

{
  "type": "data:expression",
  "data": {
    "label": "Parse Date String",
    "variables": [{ "name": "startedAt", "type": "string" }],
    "result": { "name": "parsedDate", "type": "date", "includeTime": true },
    "expression": "dateParse(startedAt)"
  }
}

Date From String With Timezone

{
  "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)"
  }
}

Date From Natural Language

{
  "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"

Conditional Logic

{
  "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"
  }
}

Related pages