Store the total value of a column

<< Click to Display Table of Contents >>

Navigation:  Low-code Process Automation > Studio Cloud - Authoring environment > 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_pin

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.

 

addrelation9

 

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.

 

Totalizer1

 

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

 

Totalizer2

 

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

 

Totalizer3

 

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

Select XPath and click 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:

 

Totalizer4

 

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.

 

Totalizer5


Last Updated 1/23/2023 12:05:09 PM