<< Click to Display Table of Contents >> Function element |
Overview
This element allows the use of functions created as library rules in each project.
Library rules and Functions are linked: Library rules receive established parameters and returns an answer. Functions provide the parameters and save the result to be used later in the rule.
On the functions element you will find a list of Bizagi functions, general functions and My functions. The first two groups are already included in the Expression element, we recommend their use from there.
My functions display a list of all the Library rules that have been created for the project. When you click a Function you will be able to include the value for the parameters in the window on the right, and store the result in a variable on the bottom right of the screen.
What you need to do in Bizagi
1. Create the library rule: Create the code, select the input parameters and set the returning value.
2. Create the rule where the function is to be called; include a function element.
3. In the function element set the output parameters and the return result.
4. Use the return result in an expression element.
Example
We have created a library rule that receives two dates and returns the difference in years.
We will use the library rule to save the date of a Customer, given the birth date.
1. Create a library rule in the element under Business Rules (Global rules). There are two parameters set: Me (which is always included to specify the context) and the date to perform the calculation.
Include the return value as the last line of code.
Bear in mind that if you are creating a function intended to be used in a Boolean expression, any parameter (except for the default parameter Me) should not use an Object Data Type. Otherwise, it will not be listed in the functions list when configuring the Boolean expression. |
2. Create the rule On Exit of the Activity where the customer enters the birth date.
Declare a variable to store the result of the function and create the Function element.
3. Expand My Functions in the Select Function field, locate and select the library rule created in step 1 i.e. Get_YearDifference. Also set a return value to the result variable created in the previous step.
In this example the library rule is under the Personal Loans Request folder, that is a family rule previously created, to help organize the library rules.
4. Finally we use the result variable to set the Customer's Age on the data model.
Last Updated 2/21/2023 9:33:14 PM