<< Click to Display Table of Contents >> Navigation: NITRO™ Workflows > Workflow Use Cases > Use Case - Update Total Cost of Purchase |
Workflow Use Case
Update Total Cost in Purchase Request with the summarized Total Cost of Items in all related Purchase Items
Description
On Purchase Request item creation, this workflow will update the Total Cost field on the Purchase Request with the summarized total cost of all related purchase items. The workflow has two actions: First it uses the Query List feature to retrieve all purchase items related to the purchase request, then a second action performs the update of the summarized total cost value.
Workflow
Add a workflow on 'Purchase Requests’ list Item create event
Action Settings:
Action 1: GetPurchaseItems (Query List Action)
Add a ‘Query List’ action to get Purchase Items related to the Purchase Request
Configure the action settings as shown in the below picture.
Query:
O365:
<View><Query><Where><Eq>
<FieldRef Name='PurchaseRequest' LookupId='TRUE' />
<Value Type='Lookup'>##ID##</Value>
</Eq></Where></Query></View>
Note: 'Purchase Request' is internal name of lookup column in 'Purchase Items' list which holds 'ID' of 'Purchase Request' items
To know more about Query List action go to Query List.
Action 2: Update Sum of All Total Costs (UpdateItem Action)
Add an ‘Update Item’ action.
Calculate the Sum and assign it to ‘Total Cost’.
Syntax: QueryLisActionName##$sum([FieldPlaceHolder])
In above example: 'Total Cost' column mapping without expression builder: GetPurchaseItems##$sum([Total Cost for Item(s)|TotalCostforItems])
'Total Cost' column mapping with expression builder:
To use Expression Builder in 'Update Action Column Mapping' refer below article
Expression Builder In Custom Actions And NITRO Workflows