Item form expressions
Make item forms dynamic and reactive to user input
An expression is a sequence of values and functions that outputs a final value.
Each control on an item form has several configurable properties (e.g. Read-only, Required). By setting a property to target an expression (instead of a static value), that property becomes context-sensitive, and will change depending on the expression's output. As expressions can read and react to the properties of all controls on the form, this makes some cool stuff possible! 😎
For example...
By targeting an expression, you can:
-
make an optional control required if another control is populated
-
make a read-only control writeable if a Checkbox control is checked
-
limit the accepted values of one Date control based on another, e.g. an End Date control that can only be set within 30 days of a Start Date control
-
sort and filter items in a Link attribute's lookup list, based on another control's value, e.g. after choosing a Team, the Team Member control only shows corresponding users
-
set the default value of a control based on others, e.g. if a Priority control is set to "High", the Target Date control defaults to 7 days after the Start Date control value
In this way, you can use expressions to regulate user input, filter the available controls on the form, and set dynamic values.
Expressions are currently unsupported on Alloy Mobile and will go unprocessed if present.
Manage a form's expressions
When editing an item form, select Expressions in the toolbar to manage the form's expressions. Any expressions defined within the form are listed on the left.
Select an expression to edit it, or select to create a new one. To delete an expression, select its button.
Developers can also include an expressions
array in their JSON code when using the Alloy API to create/edit an item form.
Target an expression
When editing an item form, selecting a control will display its properties on the right.
To make a control property target an expression, select its button and choose a saved expression from the list. The value of that property now depends on the output of the expression, which may change as the user interacts with the item form.
To clear the targeted expression, select the button.
Examples
To learn more about building different types of expression, here are some step-by-step examples: