Boolean, While and If elements
Boolean, While, and If Elements
Overview
Boolean, While, and If elements are aimed at performing different tasks but share a similar user interface because they all evaluate a condition where an action is performed or a result returned.
The condition is entered in the Expression window where three things are required:
-
To set the variable on the left side of the conditional assignment, select the relevant attribute of the data model, write an expression, or select a value from the existing vocabularies.
-
Once the element to be evaluated has been selected, enter the operator that will be used.
Depending on the type of attribute evaluated, the system will display a list of operators:ATTRIBUTE OPERATOR Numerical (integer), currency, and dates (applies to related entities relationships) Equal to, Different to, Less than, Less than or equal To, Greater than, Greater than or equal to, Is blank, Is filled. Text Equal to, Different to, Is blank, Is filled, Contains, Does Not Contain, Begins with, Does not begin with Boolean Equal to, Different to, Is blank, Is filled, Is true, Is false -
Then, on the right side of the conditional assignment, enter the value to make the comparison.
If the selection requires the inclusion of another argument, another combo will appear offering options based on the attribute (first element) selected.
You can combine several conditions. If you need to add another condition, the And button allows you to include it by means of a logical operator "And" or "Or".
Boolean Element
This element returns True or False according to the condition entered.
The following image shows a Boolean expression that returns true if the Request Status' code is 3. Otherwise, it returns false.
While Element
This element executes a cycle as long as the condition is true.
Make sure the condition evaluates to FALSE at some point to avoid generating a never-ending loop.
Example
In a Purchase Request process, after the request has been approved, it is necessary to include a certain number of quotations. This number has been previously defined. We will use a rule to create the Quotations records automatically, so the end user only needs to fill in Quotations without worrying about how many there should be. Using a While element, we will add the records until the defined number has been reached.
- Create the expression On Exit of the Approval Activity.
- Create a variable to save the number of records that are being added.
- Create the While element.
The condition will be: as long as the number of Required Quotations is greater than the number of Quotations included, add one more record.
- Create an expression element to add the records to the collection.
In this element, we will also add ONE to the variable that controls the number of records included. When this number reaches the number of quotations required, the cycle will end, and the rule will finish. (To add ONE you can type ++ in front of the attribute).
If Element
The If element offers the possibility to select one of several paths using conditionals.
The Else path will always be established.
Example
Imagine you work for a Vehicle Insurance company. As an underwriter in the company, you analyze the Policies and, according to the risk analysis, establish whether the vehicle can be covered or not. Based on your decision, the vehicle request status must be updated to "Rejected" or "Authorized by Risk."
The following is the data model of this example:
- Create a rule On Exit of the Activity where the Risk is evaluated.
- Add an If element and select the condition. In this case, select the path if the Approve Risk attribute is true.
- Include Assignment elements to set the Status of the Vehicle.
- Note that this is done using the Entity option to set the correct status using the code.
- In the Else option, the status has code 5 for "Rejected by Risk."