JEXL Evaluation And Context
Evaluation Model
A JEXL expression:
- is usually a single expression, not a block of statements,
- always returns a value,
- can use variables from the current context,
- can call built-in helper functions,
- can create object and array literals,
- can use the ternary operator instead of an
ifblock, - can call Public API functions in the form
service.entity.method(...).
Example for Hidden:
$context.form.customerSegment == 'B2B'
The result is true or false. In the Hidden property, true means that the widget is hidden.
Example for a computed value:
sumMany($context.form.items, 'price', 2)
The result is a number, for example 123.45.
Example for a data source:
crm.customer.find({ code: $context.form.customerCode })
The result is a customer object or another value according to the contract of the called API.
Context
The most common variables are:
| Variable | Meaning |
|---|---|
$build | Build metadata, for example build date/time. |
$config | Application/API configuration available to the runtime. |
$configUi | UI configuration environment data. |
$context | Current runtime context of the form or page. |
$context.form | Current form values. |
$context.entity | Main entity of the current detail page or screen. |
$outputContext | Output context used by some composed or nested runtime flows. |
$row | Current row index in table/grid-like contexts. |
$runtimeInfo | Runtime metadata, for example runtime id and related user/session information. |
$value | Current field value, object, or item depending on where the expression is evaluated. |
$version | Current application/runtime version string. |
$context.form.<field> | Direct access to a form field value. |
$context.entity.<field> | Direct access to a property of the current entity. |
.chars | Dynamic characteristics of an entity or form, if available in the current context. |
Examples:
$context.form.customer.name
$context.entity.id
$context.entity.chars.installationAddress
When accessing nested structures, remember that some intermediate object can be null or undefined. Use fallbacks:
$context.form.customer?.name ?? 'No customer'
If optional chaining is not supported in the specific JEXL field, use an explicit check:
$context.form.customer ? $context.form.customer.name : 'No customer'