Skip to content
For the complete documentation index, see llms.txt. This page is also available as Markdown.

Form expressions

Form expressions allow you to bind form components together to define a specific behavior. You can also use them for the majority of attributes and they are defined using double curly braces and a variable name, such as {{form_expression}}.

Form expressions are evaluated in the browser as JavaScript. Use JavaScript syntax and methods in your expressions. Expressions are not portable between forms and script tasks because script tasks run Groovy, where the same method names behave differently or do not exist.

When you select any form component that is visible on the canvas, you are able to enter a value in the attribute bar on the right side of the canvas. The value option is mandatory. If you specify a form label or name right after adding the form component to the canvas, the value is added automatically for you.

You can then use variables with form expressions to build dependencies between form components.

Arrays always evaluate to true even if the array is empty, so the result of {{checkBoxGroup ? 'yes' : 'no'}} is yes. To build a condition on whether an array is empty, check the length, for example {{checkBoxGroup.length > 0 ? 'yes' : 'no'}} is no for an empty array.

The following table shows common Groovy methods used in script tasks and their JavaScript equivalents for form expressions:

Groovy (script tasks)
JavaScript (form expressions)

list.contains('x')

list.includes('x')

list.size()

list.length

list.isEmpty()

list.length === 0

str.equals('x')

str === 'x'

In a custom validation, the expression describes the valid state, not the error condition. For example, the following expression prevents submitting when a non-exclusive option is combined with other selections in a multi-select field:

{{!(selection && selection.includes('None of the above') && selection.length > 1)}}

For more information on JavaScript syntax, string methods, and truthy/falsy evaluation, see JavaScript in expressions.

Some of the options available in the attribute bar allow you to switch between simple and expression modes. For example, the Required option available in the attribute bar is by default in the normal mode. However, if you would like to mark a certain field as required based on a given condition you can click the lightning bolt icon next to the Required option label to switch to the expression mode.

Last updated

Was this helpful?