Skip to content

AI: Logic and expression properties

This page defines which expression fields the agent may use and which rules it must follow.

Primary expression properties

PropertyWhen to useMust return
visibleIfShow an element (native field; return false to hide)true or false
disableIfMake an element inactivetrue or false
requireIfMake an element requiredtrue or false
readonlyIfMake an element read-onlytrue or false
resetIfClear an element under a conditiontrue or false
expressionCompute and write a valuestring, number, boolean, array, or object
validators[].applyIfEnable a validator conditionallytrue or false
validators[].conditionFailing check — error shown while truetrue or false

Other expression usage points

The agent must know that expression logic does not live only in the main fields.

Data source parameters

  • dataSources[*].paramMap[*].value
  • element actions paramMap[*].value

These can use expression fragments such as:

{personCode}
{row.id}
{__variables.route.mode}

Table columns

table.columnsConfig[*] can use:

  • visibleIf
  • controlActiveIf
  • controlEnabledIf

Event and action logic

Expressions are often used in actions in:

  • paramMap
  • action visibility or conditional execution properties, if documented in the specific action schema

When to use logicExecutionMode

If there is a dependency between fields, especially when expression is used, you typically need:

json
{
  "logicExecutionMode": "onChange"
}

This is especially important when:

  • one field fills another
  • one field changes another's required state
  • one field hides or disables another

Core writing rules

  • Use only NGX View Builder expression syntax, not full JavaScript.
  • Read field values via {fieldName} or {object.field}.
  • Use quotes for string values.
  • Use toNumber(...) for calculations to be safe.
  • Use isEmpty(...) and notEmpty(...) for empty checks.
  • Use contains, containsAny, containsAll, and len for arrays.

Correct examples

Auto-fill

json
{
  "name": "lastName",
  "type": "text",
  "expression": "{firstName} == 'John' ? 'Doe' : ''",
  "logicExecutionMode": "onChange"
}

Conditional required

json
{
  "name": "companyCode",
  "type": "text",
  "requireIf": "{personType} == 'company'",
  "logicExecutionMode": "onChange"
}

Show/hide

json
{
  "name": "vatCode",
  "type": "text",
  "visibleIf": "{country} == 'LT'"
}

Calculation

json
{
  "name": "totalAmount",
  "type": "number",
  "expression": "toNumber({price}) * toNumber({quantity})",
  "logicExecutionMode": "onChange"
}

Bad examples

Self-reference expression

Incorrect:

json
{
  "name": "el2",
  "expression": "{el1} == 'John' ? 'Doe' : {el2}"
}

Why it is wrong:

  • the element references itself
  • this leads to unstable or non-functioning logic

Correct:

json
{
  "name": "el2",
  "expression": "{el1} == 'John' ? 'Doe' : ''",
  "logicExecutionMode": "onChange"
}

Wrong type for a boolean property

Incorrect:

json
{
  "visibleIf": "'yes'"
}

visibleIf must return true or false, not a string.

Reference to a non-existent field

Incorrect:

json
{
  "disableIf": "{customerType} == 'vip'"
}

if customerType does not exist in the form.

Expression property map by need

NeedProperty
Show/hide a fieldvisibleIf (return false to hide)
Show but prevent editingdisableIf or readonlyIf
Make required only in certain casesrequireIf
Reset value when condition changesresetIf
Automatically compute a valueexpression
Enable a validator conditionallyvalidators[].applyIf
Flag a custom validation errorvalidators[].condition (error while true)

Contexts the agent may encounter

General form context

  • {fieldName}
  • {nested.field}
  • {__variables.*}

Dynamic blocks and tables

  • {row.field}
  • {item.field}
  • {parentRow.field}
  • index-based contexts, if documented in the specific location

In such cases, do not guess. If table or dynamicPanel is used, consult:

When to avoid expression

  • When the user only wants a static default text.
  • When defaultValue is sufficient.
  • When you only need to show or hide a section, not compute new data.

Final checklist

  1. Does the condition reference existing fields.
  2. Do boolean properties return a boolean value.
  3. Does expression not return the wrong type.
  4. Is there no self-reference.
  5. Is logicExecutionMode: "onChange" added where needed.