When modeling the Process, it is necessary to include the Business Rules that will help determining the path that must be followed by the process flow when:
1. Reaching the two divergent Gateways that require an expression: Exclusive and Inclusive Gateways.
2. Reaching a Conditional Task.
When these Gateways have more outgoing sequence flows than incoming ones, they are considered to be divergent. Each outgoing sequence flow must have a business rule associated for Bizagi to evaluate which path to follow. Every conditional task needs a business rule to define when should it be triggered to start.
With Exclusive Gateways only ONE business rule can be valid (true). Only ONE path can be followed.
With Inclusive Gateways one or more paths can be valid, and those will be followed.
With a Conditional Task/event, the path will only continue once the condition is valid (true).
The business rules associated to sequence flows are known as Boolean expressions, since they should always return True or False.
What you need to do in Bizagi
On the fourth step of the Process Wizard select Define Expressions.
The Process flow will be displayed highlighting the sequence flows that require a business rule to route the Process, and the Conditional Activities will be shown as enabled.
When a business rule of a path has been configured, the sequence flow will be dark.
When a business rule of a path has not been defined, the sequence flow will be highlighted in yellow.
When a business rule has not been defined for a Conditional Activity, the task will display a warning sign.
When a business rule has been defined for a Conditional Activity, the task will be shown as enabled but without a warning sign.
Click any sequence flow or Conditional Activity to associate a business rule.
Creating Business Rules for Sequence Flows
Example 1: Setting a condition
In a Purchase Request process a user creates a request. Then this request is evaluated by the immediate supervisor (Boss). According to the supervisor's decision the Process flow must follow different paths:
•If it is approved an email will be sent and the process will continue to the Quotations Sub-Process.
•If it is rejected an email is sent and the process is finished.
•If it requires changes an email is sent and the request application is returned to the applicant.
Note that the flow in the Process can only take one path, so we use the exclusive gateway.
For the supervisor to make the decision, he must choose between three options displayed in the drop-down list in the user interface a drop-down list.
For this reason, there is a relationship between the Process entity, Purchase Request, and a parameter entity, Request State.
Click the sequence flow of the rejected path.
In the new window select Based on the result of an expression. The expression tab will be enabled.
In expression, click New
The New tab will display to enter the Boolean expression.
On the left of the window you will find the Data Model. On the right side you will find the space to create the condition that will be evaluated.
•Drag and drop from the data model the attribute to be evaluated. The XPath will be automatically created, in this case: PurchaseRequest.RequestState.
•Then, choose the evaluation condition from the drop-down list. When using conditions that evaluate against a parameter entity, as in this case, the list of possible values will be automatically displayed for the user to select from the list.
•Finally select the last element of the condition to evaluate.
Click OK to save the business rule.
Continue to define all the business rules following the same procedure.
Make sure that when using an Exclusive Gateway at least one condition will return True. If not, an error message will be displayed to the end user informing there is no Task to go to.
We recommend to ALWAYS DEFINE A SEQUENCE FLOW AS ELSE.
In this case the Else condition will be defined in the Approved option of the flow.
Click on the sequence flow and in the new window select Else.
Example 2: Setting multiple conditions
Suppose in the previous example that the decision had two conditions for the Process to follow a certain path: the supervisor rejected the request OR the supervisor required changes.
In this case, it is necessary to include a second condition and to clarify that any of the options can be used, i.e., it is an OR operation.
The user can add as many conditions as needed clicking on Add condition at the bottom of the window.
At the top of the window, make sure to select the any of the following conditions option to insert an OR operator between the arguments.
By default the AND operator (all the following conditions option) is selected.
Example 3: Setting Always condition
In a Travel Request process a user creates a request. When the request has been approved by the supervisor the Process might take one or two paths according to the applicant's needs
•Always register the Hotel and Flight booking
•If needed, manage travel advance and disburse.
Since one or two paths might be opened, we will use an Inclusive Gateway.
The first condition will be left with its default value, since this will return True.
The second condition will evaluate if XPath TravelRequest.AdvanceRequired is true. This indicates that the applicant requested an Advance.
When a Boolean expression needs to evaluate a condition using a collection (a one-to-many relationship) it is necessary to use the Custom Xpaths option. This option is found at the bottom of the Data Model box.
Consider a Loans Request Process. An applicant may request several products like credit cards, personal loans and saving accounts. Some products need collateral to back up the loan (as in personal loans) and others do not.
When the request has been approved by the Risk department, the products can be Delivered (loans are disbursed)
There are some products that require the assets, used as collateral, to be registered before the products can be disbursed. These go to the Collaterals Sub-Process where the collaterals are registered before the products are Delivered. Only some products use collateral, so there are products that are not collateral-backed that may go directly to Delivery.
An Inclusive Gateway evaluates which products can go straight to Delivery (no collateral back up or Collaterals that does not require registration) and which collateral-backed Products first have to go to the Sub-Process.
In this case, the Gateway has three sequence flows: one for collateral-backed products that requires registration going to the Collaterals Sub-Process, one for the products going directly to Delivery and another one with the Is Else condition where the evaluation cannot place the product in either category and it has nowhere to go.
The business rule we are going to build will count the number of products that have collateral back up and where the collateral requires to be registered in the Collateral Sub-Process.
If there is at least one product, the rule must return True. If there are none, the rule must return False.
Click on the sequence flow and in the new window select Based on the result of an expression.
Move to the Expression tab and click New.
The business rule we are going to build will count the number of collaterals that require going to the Collateral Sub-Process.
If there is at least one product, the rule must return true. If there are none, the rule must return false.
On the boolean expression editor expand the Custom XPath options on the left and then click the Add custom XPath button.
Select the collection to be evaluated. In this case we will select the count XPath function that will return the number of products that have collateral backup (Collaterals).
As soon as a collection is selected, the XPath functions will be available for selection on the right.
We need to add a filter to be able to select only those products that requires a Sub-Process, that is, Collaterals that require registration.
To enter a filter click the Add filter condition button on the bottom. This will create a new line to enter a filter condition.
On the first column select an attribute from the Data Model.
Then select a condition value (Equals to or Is different to)
Finally select an argument. In this case our attribute is a Boolean so the argument will be the value True.
When the condition is built click Set Filter.
You can add as many conditions as you need. Then indicate whether the multiple conditions must be all fulfilled or only one requires to be fulfilled. Select either the AND or OR condition displayed below the XPath function drop-down list.
When you are done, check your XPath is correctly built as displayed at the bottom of the window.
Finally click OK.
Drag and drop the custom XPath you just built.
Fill in the condition and the argument.
In this case we include: is greater than, and the value 0.
Finally click OK.