Scripting Booleans

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Define Expression (Process routing) >

Scripting Booleans

Overview

Boolean expressions are conditional expressions that return a Boolean value when evaluated, i.e. one of true or false.
These expressions evaluate simple conditions in order to determinate behaviors or decisions based on the result.

 

Some conditions to be evaluated in order to return True or False are more complex and cannot be done with the drag and drop feature in the Business Rules interface.  This calls for the use of Scripting Booleans.

 

As Boolean expressions, Scripting Booleans can be used in:

 

Expressions associated with sequence flows (Transition conditions).

Expressions used as conditions for attributes (fields in the forms) to be (or not) visible, editable or required.

Expressions used to determine the condition to assign an activity.

 

As with Boolean expressions, Scripting Booleans are built using the Business Rules interface with access to the full range of features.

 

ScriptingBooleans3

 

 

IMPORTANT: Keep in mind that since Scripting Booleans accept any coding, it might happen that a true or a false is not returned. This should NEVER happen. Scripting Booleans should ALWAYS return a true or a false.

 

Example

Suppose in a Credit Card Request process, an Analyst enters the information of a Request made by a customer and verifies the customer's documents and references. The system automatically defines whether the Credit Card is approved or not based on the monthly income and the veracity of the documents submitted.

 

The company that offers the Credit Card has established that products will be approved in two situations:

 

If the Customer is 25 years of age or younger, the monthly income of the parent(s) or legal guardian(s) must be greater than $3,000

If the Customer is older than 25 years of age, his/her monthly income must be greater than $2,000

 

Additional to these conditions, all documents submitted must be verified and references checked.

 

In order for the system to automatically determine if the Credit Card is approved, we will use a Divergence gateway. If the approval condition is met, the gateway will route the flow to deliver the Credit Card. Otherwise a notification of rejection will be sent to the Requester.

 

 

ScriptingBooleans15

 

 

To configure the divergence conditions follow the next steps:

 

1. Go to the fourth step of the Bizagi Process Wizard and click Define Expressions.

 

ScriptingBooleans5

 

 

2. Select the path where the Business rule will be evaluated.

 

ScriptingBooleans6

 

3.In the new window select Based on the result of an expression. The expression tab will be enabled.

 

ScriptingBooleans13

 

4. A list of default and reusable expressions previously created will display.

Expand the New options and select Scripting.

 

ScriptingBooleans2

 

5. The Expressions window will display.

Include a new Expression module by right-clicking the black arrow and selecting the Add Expression option.

 

ScriptingBooleans16

 

6. Write the code to define the conditions.

Ensure that each statement returns either true or false by explicitly writing "true" or "false" followed by a semicolon.

 

ScriptingBooleans17

 

 

//Set false as default

false;

 

//Evaluate first condition

if ((<Request.CustomerAge> <= 25) && (<Requester.ParentsIncome>>3000))

{

//If fulfilled returns true

true;

}

 

if ((<Request.CustomerAge> > 25) && (<Requester.Income>>2000))

{

//If fulfilled returns true

true;

}

 

The expression shown above ensures that false is returned by default, that is, if no condition is met. Then, each condition is evaluated according to the financial company's policies. If either of these conditions are fulfilled, the expression returns true and this flow path is followed.

 

7. Include the conditions to select the alternative path.

Click the alternative path.

 

ScriptingBooleans12

 

In the new window select Else. This option will enable the alternative path if the conditions related to the main path return false.

 

ScriptingBooleans18

 

Finally, click OK.