Store the total value of a column

<< Click to Display Table of Contents >>

Navigation:  Bizagi Studio > Process wizard > Business Rules > Business Rules examples > Collections and entities > Collection examples >

Store the total value of a column

Imagine a Purchase Request process where you want to know the total price of your purchase. This value will be used to calculate discounts and to send to the requester's cost center, so it has to be displayed in the Work Portal when creating the purchase, and it also has to be stored.



Note: To display the total value of a column without the need to store it refer to: totalizers.


Thus, an attribute is created to store such value: Total Cost Estimate.


The following image displays the data model for this example:

There is a one-to-many relationship between the Process Entity Request and the collection entity ProductsRequested.

The the one is called Request.

The collection entity is called ProductsRequested.




1. Create an On Save expression to calculate the Total cost every time a product is added to the table.

For your expression, include an Assignment module.




2. Double click on the Assignment Module to edit its content. Click on Add to include a new line (assignment of information):




3. In the select variable combo, choose select attribute to specify the attribute of your data model which will store the total.




4. Next, make sure you assign to your attribute an XPath.

Select XPath and click on the highlighting XPath button.

For the XPath definition, browse to your data model’s collection and into the specific attribute which you want to add up for all of its occurrences.

Then select from the drop down list to the upper right corner, the aggregation function you need:




5. Click OK until you save all the expression.


6. On Form enter the attribute that stores the total and set it to Not editable. When a product is added to the table, the total will be calculated according to the above expression.