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, $relations, and $member, but consume results differently. $member is the member who is saving: { id }, where id is the qualified member id (members:<id>) — the same form member fields store. It is { id: null } when no member is acting, for example in system jobs. The record editor evaluates it as the signed-in member; the server repeats the check with the member who sent the request.
For a non-array multilingual text, long_text, or rich_text field, validation helpers with the value argument omitted—such as v.minLength(2)—run against every populated localized string. The first failing locale blocks the save in both the record editor and server validation. $value remains the complete localized object when the expression references it explicitly, so do not pass that object to a string helper and assume it represents one language. Test every maintained locale plus the all-empty case; a valid English value does not excuse an invalid Arabic value. 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 starts with source data and adds detected local calculated dependencies written as $.field_key after evaluating them. It exposes only configured direct/inverse relations, has no $value or $statusTemplates, and evaluates each field once. Cycles and their dependents run without calculated keys; bracket notation does not establish a local dependency.
Test calculated dependencies after background refresh, avoid cycles, and configure every relation needed by that 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; for multilingual entity text, test every populated locale independently.
  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.