StableWorkflow node
Set values
Overview
Computes named values from templates and data in scope so later steps can use them under clear names.
Purpose
Tidy up: build an email subject once, derive a full name, pick a field out of an API response, or set a constant for several following steps.
Inputs
- Values — a list of key + value pairs. Each value is static, dynamic or a template (
{{record.first_name}} {{record.last_name}}). Keys may contain letters, digits and underscores. - Calculation (beta, plan / config level) — instead of a value, a formula such as
{{results.onhand_sum}} - {{event.quantity}}: numbers,{{references}}, + - × ÷, parentheses and the functions min(), max(), round(x, places) and abs(). Computed exactly with 6 decimal places (half away from zero).
Configuration
- Templates produce text; dynamic values keep their type (numbers, lists, objects).
- Later Set values steps can overwrite earlier keys.
Outputs
- Each pair becomes
results.<key>(Action results › key,{{results.key}}); a calculation stores a number. Step output: the list of result keys.
Example
Prepare email fields
Example
Set values
greeting = Hi {{record.first_name}},
subject = Your appointment on {{record.date}}
staff = {{user.name}}
Send email: Subject = {{results.subject}} · Body = {{results.greeting}} …Errors
- Calculations fail the step with “<key>: Division by zero”, “{{event.quantity}} has no value” or “… is not a number” — a run started by a button or form then rolls back its writes.
Limitations
- Templates only substitute values; arithmetic is only available as a calculation (no text or date functions). Calculations are written in the app plan or the step's config — the step panel does not edit them yet.
Advanced
- Config:
{ assignments: { key: string; value?: Binding | string | unknown; calc?: CalcExpr }[] }. The executor evaluates each value (or calculation) and writesresults[key](applyAssignments, shared with the sandbox). - CalcExpr is an allowlisted AST (src/core/bindings/rules.ts): num (decimal literal), ref (a Binding), op (+ - * /), neg, fn (min, max, round with places 0–6, abs); at most 60 parts and 12 levels. Unknown operators are rejected when the workflow command is applied. Plan syntax:
{ type: "calculate", as, formula }(parsed byparseCalc). - Date functions: adddays, addmonths, daysbetween (UTC calendar days); addhours, addminutes, hoursbetween, minutesbetween (exact UTC instants); beta business-hours functions addbusinesshours, addbusinessminutes, businesshoursbetween, businessminutesbetween (working time in a business calendar —
fnnode with optionalcalendarkey, formula syntax `addbusiness_hours(x, 8, "support"); default = the app'sdefault` calendar or Mon–Fri 09:00–17:00 in the app's time zone; src/core/business-hours.ts). Unknown calendar keys fail the step with a readable error.