Applies to version: 2021.1.x and above; author: Konrad Wojtycza
Introduction
WEBCON BPS Designer Studio allows users to configure global business and form rules. As global rules, they are available for all applications created in a given environment and thanks to parameters they are universal and may be used in multiple processes.
Global business and form rules can be configured by choosing “Business rules” or “Form rules” items from the left selection tree in the “System settings” section. After selecting one of the above-mentioned items, it is possible to add a new rule (“New rule”) or a group of rules (“New group”) by using respectively the “New rule” or the “New group” button located in the upper bar.
The “New rule” and “New group” buttons
Once a rule is added, you can add parameters to it. To do that select the “Parameters” tab on the left and click the “+” icon. The newly opened window allows you to edit the parameter including (only in the case of business rules) its type. (Available options: “Text”, “Decimal”, “Boolean”, “Date”, and “User list”.) Remember to attribute a proper data type to a parameter.
Setting up a required parameter type
The following chapters present examples of business and form rules with parameters.
Global business rules
This rule verifies whether an attachment is added on a particular step. The verification is executed by means of an SQL query that checks whether an attachment is added to an instance after defined time (date and time).
A business rule with a conditional clause
The rule is used to check an attachment is added on a particular step.
An SQL query used in the rule
After entering the global business rule, insert a form field that includes the parameter value in the rule configuration.
In the presented example the “Step entry date” form field is populated with the date of entering the “Business owner verification” step.
The business rule inserted in the "Validate form" action
It is possible to use simultaneously global business and form rules. The screenshot below presents the “Get exchange rate” global business rule which downloads PLN exchange rate for defined currency code (“EXC_Code”) and exchange rate date (“Exchange rate date”).
The “Get exchange rate” rule and its parameters
An SQL query used for downloading the aforementioned exchange rate is presented in the below screenshot.
NOTE: to use the “ExchangeRates” table it is necessary to enable exchange rate synchronization in the service configuration beforehand.
An SQL query used in the rule
The “HasDuplicate” business rule checks if there is an instance with the same value of the defined field in the system.
The “HasDuplicate” rule with a conditional clause
The configuration of this rule is presented in the below screenshot – the rule’s parameters include the “ColumnValue” parameter (taking the value of a defined field) and the “ColumnName” (taking the name of a column in a database).
An SQL query used in the rule
By using the above-mentioned rule it is possible to verify e.g. occurrence of instances with the same invoice number.
The “HasDuplicate” rule inserted in the “Validate form” action
By means of the “Instance was in step” rule it is possible to check if a particular instance was present in the defined step. The parameter used in the rule is the step identifier “STEP_ID”. The rule is used in the on-path “Change value of single field” action. A technical field “ _Was in Consultations step” is filled out on transitioning the path.
This rule can be useful, .e.g. as an action execution condition when execution of an action is dependent on whether an instance was present in a given step.
An SQL query used in the “Instance was in step” rule
The "Instance was in step" rule inserted in the "Change value of single field" action
The “LastValue” business rule returns last value entered in a field defined by means of the “ColumnDBName” parameter.
An SQL query used in the “LastValue” rule
In a demonstrative configuration, the rule is used in an action inserted on the “Save” path. After each saving, the “Last value” field is populated with a pre-saving value of the “Invoice description” field.
If you enter “Jeden” value in the “Invoice description” field and save the form, the “Last value” field remains empty. Then, when you enter “dwa” value in the “Invoice description” field and save the form, the “Last value” field is populated with the “Jeden” value, i.e. the value preceding the last saving. By filling out the “Invoice description” field with the value “trzy” and saving the form, the “Last value” field is ultimately populated with the value “Jeden dwa”.
The "LastValue" rule inserted in the "Change value of single field" action
The "LastValue" rule operation in practice
The “Path was used” rule returns information on whether a path defined in the “PATH_ID” parameter (path identifier) has been used.
An SQL query used in the "Path was used" rule
In a demonstrative configuration, the rule is used in the “Change value of single field” action inserted on the “Save” path. After transitioning the respective path, a value is entered in the form in the “_Has been saved?” technical field.
The "Path was used" rule inserted in the "Change value of single field" action
Global form rules
The screenshot below presents the global form rule “Set converted on the basis of exchange rate” that can used together with the “Get exchange rate” business rule. This rule is used for converting the value under the “Amount” parameter to the value under the “Converted” parameter using the exchange rate defined by the “Exchange rate” parameter.
The “Set converted on the basis of exchange rate” rule with its parameters
The “Set converted on the basis of exchange rate” is used in the configuration of the “Exchange rate date” and “Exchange currency” form fields. The rule is executed on changing the form fields value. The “Get exchange rate” business rule with “Exchange rate date” and “EXC_Code” parameters is provided as the “Exchange rate” parameter.
The rule inserted in a respective form field
Once you select the date (the “Exchange rate date” field) and the currency (the “EXC_Code” field), the “Gross amount” value is converted to the “Gross amount in foreign currency” value.
The rule operation in practice
Form rules are often used to hide or show form fields after selecting a checkbox. A global rule that can be used to this end is presented in the below screenshot.
Parameters used for its purpose are: “Checkbox” and “Field”. Once the rule is applied in configuration of a selected form, changing value of a checkbox (defined as a parameter) results in changing the form field associated with the “Field” parameter. A demonstrative configuration of the rule and behavior of a form are presented in the below screenshots.
The „Show/hide” rule with conditional clause
The „Show/hide” rule inserted in a respective form field
The “Show/hide” rule operation in practice