Applies To: SharePoint On Premises and SharePoint Online
Description:
In our Asset Management Module we have a field “Total Maintenance Cost” in “Assets” list. Also we have maintenance tasks that will be created periodically based on the scheduled preventive maintenance feature for the assets. This article describes how to update “Total Maintenance Cost” in Asset with the sum of its related maintenance tasks cost.
Summary of Steps:
- Configure a workflow on “Tasks” list on “an item is created” event that finds all the related tasks and update the total cost.
- Configure a workflow on “Tasks” list on “an item is modified” event that finds all the related tasks and update the total cost.
Detailed Steps:
- Configure a workflow on “Tasks” list on “an item is created” event that finds all the related tasks and update the total cost.
Step 1: Open Workflow manager and configure a new workflow on “Tasks” list on “Item is created” event as shown below
Step 2: Configure a Query List Action as shown below
Query used in above action:
<View>
<Query>
<Where>
<Eq>
<FieldRef Name='Asset' LookupId='TRUE' />
<Value Type='Lookup'>##Asset##</Value>
</Eq>
</Where>
</Query>
</View>
Step 3: Configure an “Update Item” actin to update the “Total Maintenance Cost” for the Asset list as shown below
Column Value in the above field mapping: <<todo>>
Syntax: QueryListActionName##$sum(Task Cost from tasks columns)
The above field mapping is build using the “Column Mapping” dialog as shown below.
With the above workflow configuration, on every task creation, it fetches all the related tasks for the asset, sums up all the related task cost and updates in the Total Maintenance Cost.
2. Configure a workflow on “Tasks” list on “an item is modified” event that finds all the related tasks and update the total cost.
Configure another workflow on “an item is modified” event (See sample screenshot below) on “Tasks” list with same actions settings as above.