Reusing Business Rules
Overview
In Bizagi, you can reuse business rules to accelerate your implementations
and build and maintain processes more efficiently.
Reusability in Bizagi is promoted by creating business rules only once and then associating them
to the BPMN shapes of the processes whenever required.
Types of Business Rules
There are two types of business rules:
• Boolean Rules
These rules must only return True or False.
They are used for:
- Routing the Process (rules associated with sequence flows).
- Conditions for attributes in forms (to determine if fields are visible, editable, or required).
To make a Boolean rule reusable, tick the Reusable checkbox in the lower-left corner.
• Scripting Rules
These rules perform calculations and validations.
They do not have to return any specific data type.
They are used for:
- On Enter, On Save, or On Exit actions
- Validations in Tables within Forms
- Buttons on Forms
Scripting rules are always reusable but depend on the context/scope in which they were created.
They can be reused in:
- Any Process in the entire project
- Any Process within the same application
- Only the same Process
Context/Scope of Business Rules
Bizagi has four levels where business rules are saved, determining their reusability.
• Global Rules / Library Rules
- Can be Boolean or Scripting rules.
- Accessible and reusable by all Processes in all applications.
- Perform general calculations without context.
- If a rule is created as a Function, it will be used as a Library Rule.
📌 Note:
Library rules cannot access the Data Model, so XPaths cannot be used.
• Application Rules
- Can be Boolean or Scripting rules.
- Reusable by all Processes within a single application.
- Perform general calculations within the shared context of the application.
• Entity Rules
- Can be Boolean or Scripting rules.
- Reusable by any Process in any application if the entity is part of the Data Model.
- Boolean rules manage visibility, editability, or required attributes.
- Scripting rules are attached to buttons and validate Tables.
• Process Rules
- Can be Boolean or Scripting expressions.
- Reusable exclusively by the same Process.
- Boolean rules control Process routing.
- Scripting rules are used for On Enter, On Save, and On Exit actions.
When creating rules through the fourth step of the Process Wizard,
they are automatically stored as Process rules.
Example of an Application Rule
For a loan application, initial applicant information must be provided.
Before accepting the applicant as a client, some form controls must be shown or hidden.
A visibility rule must be created that can be used in multiple forms within the same process.
📌 Note:
This rule has a context since it relates to the applicant of the request.
Thus, the context will be the Process Entity of the parent process.
- In Expert View, go to Business Rules.
- Right-click Expressions in the Application where you want to use the rule.
- Select New Expression.
- Choose Boolean Rule.
- Drag and drop the data to evaluate and set the condition.
- Name the rule and optionally assign it to a Rule Family.
Using the Rule in Forms Modeler
- Open Forms Modeler.
- Select the attributes to hide if the applicant is an existing client.
Example of an Entity Rule
In a Purchase Request Process, a user enters multiple products.
For each product, the unit price and quantity must be specified.
A calculation is needed to automatically compute the total price
when the record is saved (Unit Price × Quantity).
- This calculation is performed using an Edit Validation Expression.
- The rule is automatically saved in the collection entity.
- It can be reused by any Process that includes the collection entity in its data model.
Steps:
- In Forms Modeler, select the Table where the rule will be applied.
- Select Edit Validation Expression to open a Scripting Rule editor.
- Write the required code.
- Since this rule applies to a collection, its context is the collection entity (Products Requested).
📌 When a user saves a product, the total price is automatically calculated.
Example of a Process Rule
Bizagi stores Process Rules for:
- On Enter
- On Exit
- On Save
- Routing Rules
Example:
A Boolean Process Rule is used to route the Purchase Request Process.
This rule determines whether supervisor-requested changes must be made
before continuing to the Quotation Sub-Process.
How to Reuse a Rule
To reuse a previously created rule:
- Go to the Sequence Flow where you want to apply the rule.
- Open the Expression Manager.
- Select Based on the result of an expression.
- A list of available reusable rules will be displayed.
- Select the desired rule and click OK.