chesterdocs

#Write an expression

An expression is one JavaScript expression that reads the process data by element id and field name, with the usual operators, array and string methods, Math, Date and JSON — but no statements outside a function and no outside access.

#How an expression is read

flowchart LR
  E["Activity_fetch.creditLimit >= StartEvent_order.amount"] --> V{"Checked while you type"}
  V -- "syntax, known ids,<br/>result type" --> OK["✓ and the result type"]
  V -- "problem" --> P["Message on the field"]
  OK --> R["Evaluated when the<br/>process reaches the step"]
  R --> D["It gets the data<br/>it names"]

#Read process data

Every value comes from the process data, by the element id of the step that produced it and the field name:

Write Reads
StartEvent_order.amount a field of the start data
Activity_fetch.customer.name a nested field of a step's result
Activity_fetch.items[0].sku an item of a list
Activity_fetch_all[2].status a run of a multi-instance step
__INITIATOR.email the person who started the process
__loop.item, __loop.index the current item and its position, inside a multi-instance step

The + button next to a field inserts such a reference for you.

⚠️ __INITIATOR is empty when a process was started without a person — for example by a webhook.

⚠️ A field name with a - or a space cannot be written this way. Use brackets: Activity_fetch["order-id"] — the variable list does not do that for you.

#What you can write

  • Operators: + - * / %, comparisons === !== < <= > >=, && || !, the conditional a ? b : c, ?. and ??.
  • Text in quotes, `template ${text}`, numbers, true/false, null, lists [ … ] and objects { key: value }.
  • Methods of lists and texts: map, filter, find, some, every, reduce, includes, join, slice, length, toUpperCase, trim, split, replace and more.
  • Math, Date, JSON, Number, String, Boolean, Array, Object, parseInt, parseFloat, encodeURIComponent, atob.
  • A function only as the argument of a method — items.map(i => i.price) — or called on the spot: (() => { const total = …; return total * 1.19; })(). Inside such a function you can use const, let, if and loops.

An expression is one expression: const x = 1; x + 1 on its own is refused.

#What you cannot write

  • ❌ Anything outside the process: no database, no network, no other instance.
  • ❌ console, globalThis, btoa, Intl.
  • ⚠️ Number and date formatting for a language, such as toLocaleString("de-DE"), is accepted, but the language is ignored.
  • ⚠️ async functions do not work: their result is never waited for.

#When a value is missing

Missing What happens
The element id — the step did not run on this path The expression fails, and with it the step
A field of a step that did run The value is undefined; what happens next depends on where the expression is used
A field inside a missing field — a.b.c without b The expression fails

To use a step that only runs on some paths, guard it: typeof Activity_review === "undefined" ? "none" : Activity_review.comment. Activity_review?.comment does not help when the step never ran.

#Limits

  • An expression may be at most 4096 characters long, and may take at most 10 seconds.
  • The data it reads may be at most about 1 MB.
  • A text result that looks like JSON — "{…}" or "[…]" — is turned into an object or a list. JSON.stringify(x) therefore does not stay a text.

#What the editor checks

While you type, the field checks the syntax, that every element id you use exists before this step, and whether the result has the type the field expects. It shows ✓ with the type, or the problem. Checks go one level deep: Activity_fetch.a is checked, Activity_fetch.a.b is not, and nothing inside a function is.

⚠️ The syntax and reference messages are German, whatever the language of the screen.