Skip to main content

The context is part of the expression

An expression has no universal data model. A line that is correct in a calculated field can be blank, unsafe, or silently misleading in a form, serial format, or document template. Use this matrix before you reuse an expression. KayanOS serial-format expression editor showing the roots and helpers available for a Citizen Service Request reference.

Entity defaults

Entity defaults use $record, not $. The server evaluates a configured default only when the corresponding value is absent or empty.
Use defaults to provide an initial value, not to prove that a person reviewed a decision. Keep an important confirmation as an explicit field or action condition.

Entity rules and validations

Entity field visibility, editability, and custom validation share $, $value, and $relations, but consume results differently.
The server treats an evaluation failure in a visibility rule differently from an evaluation failure in an editability or validation rule. Do not use a malformed expression as a policy mechanism. Test the visible, editable, and invalid paths separately with a non-production record.

Calculated fields: preview is not background processing

The interactive/synchronous calculation path can expose $value, configured direct relations, an empty inverse relation object, and status templates. It can iterate through calculated fields. The background job strips every calculated output from $, exposes only configured direct/inverse relations, has no $value or $statusTemplates, and evaluates each field once.
Avoid a calculation that needs another calculated output or a relation that is not configured for the background path. See Calculated fields for the full execution model.

Error and empty-value behavior

Roots are data contracts, not convenience names

Use a context root that is actually provided. For example:
The first expression is not automatically a valid default or document-template expression. Use the editor as syntax assistance, then validate the result in the real feature.

Review checklist

  1. Identify the exact runtime in the matrix.
  2. Confirm source key names and data types with a known safe record.
  3. Test empty, normal, and exceptional data.
  4. For dates, test the intended timezone boundary.
  5. For lookups, test least-privileged data and do not display unnecessary fields.
  6. Record the policy decision outside the expression when it affects access, approval, or public delivery.