Axelor Doc

Expressions Javascript

The client side javascript expressions (ie executed by the browser) below, to configure the attributes of the widgets:

  • requiredIf
  • readonlyIf
  • collapseIf
  • showIf
  • hideIf
  • validIf

The terms used are expressions AngularJS simple and not javascript expressions. However unlike angularJs, expressions are evaluated in isolation with the values of the current record and additional values (helpers) available in the context.

The "helpers" include in particular fields of type date / datetime or decimal because they are saved as a string and must be translated.

The helpers are available:

  • $moment(d) converts a date / datetime field
  • $number(d) converts a decimal field
  • $popup() returns true if the current view is used in a pop-up window. (Useful to hide a field in the main view or view pop-up)

A few examples:

<field name="createDate" readonlyIf="confirmed"/>

<field name="confirmDate" requiredIf="confirmed"
    validIf="confirmDate == null || ($moment(createDate) &lt;= $moment(confirmDate))"/>

<group title="Actions" collapseIf="lastName == null" />

<notebook ... hideIf="lastName == null" />

<field name="amount" validIf="$number(amount) &gt;= 100" />

<field name="password" validIf="password.length &gt; 5" />
<field name="confirmPassword" validIf="password === confirmPassword" />

<group title="Quick Info" showIf="$popup()">
...
</group>