Configuring Dynamic Field Display Using a Form Rule
Table of Contents
Use Case
In the CMW Platform, you can define a set of rules for any form to control its element behavior.
Each rule can include several conditional actions:
- Set field values
- Show field validation warnings and error messages
- Change element access mode: require entry, allow entry, read-only
- Hide elements
In this article, we will define a form rule to show the hidden fields only when the preceding fields are filled.
Prerequisites
In the example scenario, when creating a business trip request, an employee selects the destination country, city, and airport.
To streamline the user experience, we initially show the Country hide field and hide the City and Airport fields. When the user selects the country, the City field appears. When the user selects the city, the Airport field appears.
To proceed with the example, set up the template, attributes, and form fields as shown in the table below:
Record template name | Attribute and field display name (system name) | Field Access setting on the form |
Travel requests |
Country (request_country) |
Require entry |
City (request_city) |
Hide | |
Airport (request_airport). |
Hide |
Instructions
- In the Travel requests template, open the default form.
- Open the Form rules designer using the dropdown next to the form heading.
- Add a rule and an action to the rule.
- Configure the Action properties.
- From the Form element dropdown, select the City (request_city) field.
- From the Action dropdown, select Change access.
- From the New value dropdown, select Require entry.
- In the Execution condition field, enter the formula:
NOT(EMPTY($request_country))
- Add a second action to the rule.
- Configure the Action properties.
- From the Form element dropdown, select the Airport (request_airport) field.
- From the Action dropdown, select Change access.
- From the New value dropdown, select Require entry.
- In the Execution condition field, enter the formula:
NOT(EMPTY($request_city))
- Click Save.
Formula Syntax
Element | Description |
---|---|
NOT() |
This function returns |
$ |
This prefix refers to an attribute in the current record context. |
|
This function returns true if its argument has an empty value. |