chesterdocs

#Expression examples

Ready-made expressions for the common cases — conditions, defaults, sums, picked fields, dates, text, request bodies, multi-instance results, the initiator and files.

The ids below — StartEvent_order, Activity_fetch — stand for the element ids in your process. Pick yours with + in the field.

flowchart LR
  S["StartEvent_order<br/>orderId, amount, orderDate"] --> F["Activity_fetch<br/>customer, items[]"]
  F --> G{{"Gateway"}}
  G --> R["Activity_review<br/>(only on some paths)"]
  G --> N["Next step:<br/>the examples read these"]
  R --> N

#Conditions on a gateway

Goal Expression
Amount over a limit StartEvent_order.amount > 1000
Both must hold StartEvent_order.amount > 1000 && Activity_fetch.customer.isNew
A list is not empty (Activity_fetch.items || []).length > 0
A text is one of several ["DE", "AT", "CH"].includes(Activity_fetch.customer.country)

#A default when something may be missing

Goal Expression
A field that may be empty Activity_fetch.customer.phone ?? "none"
A step that ran only on some paths typeof Activity_review === "undefined" ? "not reviewed" : Activity_review.comment

Activity_review?.comment is not enough when the step never ran — see Write an expression.

#Work with lists

Goal Expression
Sum Activity_fetch.items.reduce((sum, i) => sum + i.price * i.qty, 0)
Only some items Activity_fetch.items.filter(i => i.inStock)
One field of every item Activity_fetch.items.map(i => i.sku)
The first match Activity_fetch.items.find(i => i.sku === "A-100")
Options for a select, in Option data Activity_fetch.items.map(i => ({ value: i.sku, label: i.name }))

#Dates and text

Goal Expression
Today, as 2026-09-30 new Date().toISOString().slice(0, 10)
A date as 30.09.2026 (() => { const d = new Date(StartEvent_order.orderDate); return String(d.getUTCDate()).padStart(2, "0") + "." + String(d.getUTCMonth() + 1).padStart(2, "0") + "." + d.getUTCFullYear(); })()
Text with values `Order ${StartEvent_order.orderId} for ${Activity_fetch.customer.name}`
Text depending on a value StartEvent_order.amount > 1000 ? "needs approval" : "approved"

⚠️ Formatting for a language — toLocaleDateString("de-DE") — is accepted, but the language is ignored. Build the text yourself, as above.

#A request body

{
  customer: { id: Activity_fetch.customer.id, email: Activity_fetch.customer.email },
  total: Activity_fetch.items.reduce((sum, i) => sum + i.price * i.qty, 0),
  note: `Order ${StartEvent_order.orderId}`
}

Write it with ƒ on the Request body — see Fixed values, variables and expressions in a field.

#Multi-instance

Goal Expression
Inside the step: the current item __loop.item.email
Inside the step: its position __loop.index
After the step: every result Activity_notify.map(r => r.status)
After the step: were all approved? Activity_approve.every(r => r.approved)
After the step: the first result Activity_notify[0].status

With First completion or Number of completions, the list after the step holds only the runs that finished — see Run a step once per item.

#The initiator

Goal Expression
Their email __INITIATOR.email
Their full name `${__INITIATOR.firstName} ${__INITIATOR.lastName}`

⚠️ Empty when nobody started the process by hand — for example a webhook start.

#Files

Goal Expression
Send a file's content in a request body { document: Activity_upload.invoice.file }
Attach a file to an email Activity_upload.invoice in Attachments
A file's name Activity_upload.invoice.fileName

.file loads the file itself only in a request body, in the email fields and in attachments; elsewhere it is an ordinary field name.

#A message filter

Goal Expression
Only one kind of event payload.event.type === "invoice.paid"
Ignore messages from bots !payload.event.bot_id
By a header headers["x-source"] === "shop"

A filter reads only the request — see Where expressions are used.