Applies to version 2020.1.3; author: Franciszek Sakławski
Introduction
By creating dependencies between form fields on the form, fields are repeatedly calculated based on the basis of other fields. To correct calculations, remember to properly set their order. This article describes several examples of dynamic field calculation, and then in a tabular form the order od execution of rules for both the Modern and Classic form ha been presented.
Description of the functionality
Below two examples of dynamic field calculation have been described.
Case 1
Three fields - 1 picker field and 2 text fields are defined on the form
Fig. 1. The advanced configuration of the Picker field
In the “Country” field select that the “Description” column will fill in the “Country code” field. Then, when changing the value of the :Country code” field, place the form rule filling the “Is Poland” value field with the desired value:
Fig. 2. Style and behavior tab
After selecting the value in the “Country” field, all three fields should be filled with the value:
Fig. 3. Filling the field with the value
Case 2
Three fields - 1 picker field and 2 text fields are defined on the form
Fig. 4. Style and behavior tab
In the “Style and behavior” tab of the “Country” field, set the form rule that changes the “Country code” field value. Then set the change of the “Country code” field value to refresh the default values on the form.
Fig. 5. The configuration of the “Country code” field
In the “Is Poland” field set the default value according to the “Country code” field:
Fig. 6. The “Is Poland” field default value
Business rule
On the form, you can also create business rules that can use integration tools such as SQL query or Data Source Value. Let’s create a rule and implement it in the “Style and behavior” tab. To present the abilities of business rules, take the “Name” value of the “Countries” dictionary process element.
The dictionary element from which you will retrieve the data has an ID with the value "ff024404-ef6e-46ec-a8a1-9cd8c63df0a3". The form looks like this:
Fig. 7. Dictionary element
In the business rule, embed the SQL query that refers to the telephone code of a given country. If you enter “+48” in the field, the system should find a dictionary element containing country data with such code.
Let’s go to WEBCON BPS Designer Studio and create a rule. At the bottom of the process, expand the "Configuration" field and then the "Business rules" field. When the new screen opens, click the 'New rule' button.
Fig. 8. Adding the business rule
Then in the expression editor, select the “SQL COMMAND” and create the SQL query referring to the element and save the rule.
Fig. 9. The configuration of the business rule
You can add this rule to the rules executing on the field change value. In the “Country code” field configuration enter this rule as a default.
Fig. 10. Filling in the field with value
The execution order of the form rule for the Modern and Classic forms
MODERN FORM
Form rules executed on page load
Forms executed on value change
If in the form field configuration the “Change of value generates postback” field is set, the rule execution order is as follows:
No. | Configuration | Tab | Field name | Link |
1 | Form field configuration | Style and behavior | Form rule to be executed on value change | |
2 | Form field configuration | General | Default value |
CLASSIC FORM
Form rules executed on page load
Forms executed on value change