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:- The feature that evaluates it: entity default, entity rule, calculated field, form, serial configuration, or document template.
- The exact field key or context root, rather than a visible label.
- The required output type: Boolean, Number, text, date, validation result, or list.
- How an empty value, lookup failure, or error should behave.
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.
Filter a list
Relative filters use. for the item currently being considered:
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:
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:| as its first argument:
- Math helpers, string helpers, date and time helpers, and array helpers
- Comparison and conditional helpers and common conversion helpers
- Validation helpers and legacy aliases
- Form helpers and lookup filters, serial helpers, and document-template lookup
- Project helpers and planning helpers
Templates, lists, and objects
Backtick templates combine fixed text and evaluated values. Put the evaluated expression inside{{ and }}:
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:
Validation expressions are not ordinary conditions
Validation helpers returntrue 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.
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
Avoidrandom, 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.
Related guides
- Expressions in the builder
- Calculated fields
- Forms, fields, and repeatables
- Serial IDs
- Document templates


