Skip to main content

Start with the execution context

An expression returns a value. The feature that evaluates it decides whether that value becomes a calculated field, a visibility decision, a validation result, form text, a serial number, or document output. The same spelling is not automatically valid everywhere: available root variables and context-specific functions differ. Before writing an expression, identify all four of these facts:
  1. The feature that evaluates it: entity default, entity rule, calculated field, form, serial configuration, or document template.
  2. The exact field key or context root, rather than a visible label.
  3. The required output type: Boolean, Number, text, date, validation result, or list.
  4. How an empty value, lookup failure, or error should behave.
Read expression contexts and availability before copying a working expression into another feature.

Values and paths

Literals

Read a value

The root comes from the context. Entity rules commonly expose the current record as $; document templates expose it as $record.
Use dot access for ordinary keys and brackets for a numeric index or a key that is not a simple identifier:
Do not guess a key from its translated title. A robust expression refers to the stable field key configured in the builder.

Filter a list

Relative filters use . for the item currently being considered:
Treat an empty result as normal. Test it before using a list as the basis for a critical decision:

Operators and precedence

Use parentheses whenever arithmetic, comparison, and logical decisions are mixed. They make policy review easier and prevent accidental reliance on precedence. For a fallback, write the logical-OR operator in an expression block rather than placing its two pipe characters inside a Markdown table cell:
The helper eq(left, right) intentionally uses loose equality, while binary == does not. Prefer binary == for stored option values; use eq only when deliberate type coercion is part of the policy.

Textual and, or, and xor

Textual operators exist for validation-oriented expressions, but their validation-message behavior differs between the shared builder runtime and document-template runtime. They are not a portable way to aggregate several human-facing errors. For ordinary Boolean/value logic, prefer && and ||. For field validation, use the validation helpers in the exact validation context and test the returned message.

Functions and pipe transforms

Most general helpers have two equivalent forms. A function receives all arguments explicitly:
A transform receives the value to the left of | as its first argument:
Use the version that reads best. Validation functions, form lookup/filter helpers, and the document-template lookup helper are function calls only. Form-only and serial-only helpers are not general calculated-field APIs; their availability is stated on each reference page. Browse the complete reference by task:

Templates, lists, and objects

Backtick templates combine fixed text and evaluated values. Put the evaluated expression inside {{ and }}:
An interpolation that resolves to null or undefined becomes an empty string. That avoids displaying the word undefined, but it can hide missing data. Add an explicit fallback for any public-facing sentence. You can create a small list or object for local logic:
Spread syntax can combine an already structured value with a new item:
Keep these structures local to the expression. If staff must search, approve, report on, or audit a value, store it in a normal field instead.

Validation expressions are not ordinary conditions

Validation helpers return true when valid and a localized error result when invalid. In a field-validation context, helpers such as v.required() can receive the current field value automatically through $value.
Entity validation and form validation do not consume every return value in exactly the same way. A form, for example, treats true, null, undefined, and an empty string as valid; an expression error can be handled differently from an entity validation error. See validation helpers and expression contexts before publishing a rule.

Determinism, dates, and safe use

Avoid random, shuffle, sample, and sampleSize in serial formats, persisted calculated fields, or auditable decisions. Avoid relying on the live clock without a refresh policy: now(), isToday, isTomorrow, isYesterday, and getAge can change without a record edit. Date helpers do not all use one timezone model. Some calendar helpers use local date setters while dateAdd, comparison units, component extraction, and dateFormat use UTC-oriented behavior. Use an ISO-like source value, state the intended timezone in the field description, and test values around midnight and daylight-saving boundaries when applicable. dateFormat uses YYYY, MM, DD, HH, mm, ss, and SSS. This is different from the smaller serialDate vocabulary (yyyy, yy, MM, dd).

Test and troubleshoot

KayanOS Automations does not provide this expression runtime as a general trigger/action configuration language. Use this reference only where a KayanOS builder field explicitly supports expressions. KayanOS expression syntax in a builder field