Create rules in the form
This topic will teach you how to create rules in a form.
We will use the example for creating a travel request form.
To this end, simply follow the steps below:
1st step: Create a rule
For this step, go to the FO005 menu and, in the Quick search field, search for the form created in the Create a form without revision control topic.
Before creating the rule, we will change the property of the Return date field to disabled, as shown in the image below.
After doing that, go to the Rules tab and click on the New rule button.
On the screen that will open, enter the rule name as "Return or One way" and click on the Save & close button.
Thus, we have successfully finished the creation of a rule!
The next goal is to add a condition to the rule that we have created.
To do so, keep the form editor screen open.
2nd step: Create a condition
To create a condition, select the created rule in the modeling area.
Click on the Add action button and select the "Create conditional expression" option.
After doing that, on the "IF" screen, click on the Add condition button.
Inside the conditional expression panel, you can create conditions.
Conditions are intended for validations concerning the business rule of the form. In our condition, we will check if the option group value is Return.
The Return date field will be enabled only if this value is selected because, by default, it will be disabled.
To do that, take the following steps:
1. On the condition screen, select the "Form field" option for the value source.
2. In the form field, select the "Option group" option and select "Equal" for the comparison operator.
3. Then, select the "Fixed value" option in the second value source field to compare with the form field.
4. In "Type", select the "Text" option, enter the "Return" text for the comparison and click on the Apply button.
As a result, the rule will be set as follows:
If the value of the [Option group] form field,
Is equal to the [Return] fixed value,
Then, do something.
After doing that, click on the Save & close button.
Thus, we have successfully created a condition!
3rd step: Create a property change action
With the condition duly configured, we will create an action to be executed if the condition is true.
To this end, keep the Rules tab open and click on the Add action button inside the condition.
After doing that, select the "Set property" option.
On the screen that will open, select the element that we will change: "Return date".
In the Property field, select the "Enabled" option
If it is the name of a field: Value, select "Yes".
Thus, the "Return date" field will be enabled if the condition is true.
After doing that, click on the Save & close button.
Done. We have successfully created a property change action!
4th step: Create an action for false condition
To create an action, if it is false, keep the Rules tab on the form editor screen open and click on the Add Else button.
Then, click on the button to duplicate the property change action.
After doing that, click on the directional arrow of the property to add it to the ELSE and on the button.
In the Value field, select "No" and click on the Save & close button.
Thus, the rule is duly created.
Therefore, if the field value is "Return", the "Return date" field will be enabled; otherwise, the field will be disabled.
5th step: Relate a rule to the field event
After creating the rule, we will relate it to the change event of the "Option group" field.
To do so, go again to the Form tab and select the "Return/One way" field.
In Property panel > Rule, enter the "Return or One way" rule in the Change field, as shown in the image below.
To view the result, click on the Preview button.
Done. Now you already know how to create rules and use them in the form!