<< Click to Display Table of Contents >> Navigation: NITRO™ Workflows > Workflow Use Cases > Use Case - Using Usercollection for multi-user field updates |
Workflow Use Case
Using the ‘Usercollection’ Function
Description
The Usercollection function allows you to combine single user values into a mulit-user enabled field automatically. This function can be used directly in Column/Field Mappings or as part of a workflow WF Variable action. The following examples illustrate its use in each scenario.
Examples
1) In Field Mappings
In this scenario we have a multi-user enabled field ‘Approvers’ and two user fields ‘User1’ and ‘User2’.
We want to update the multi-user field ‘Approvers’ with users in fields ‘User1’ and ‘User2’.
To do this use the ‘usercollection’ function in Field Mappings as shown below.
2) With WF Variable Action
In the second scenario we have a field ‘Approvers’ in the Configurations list where different approvers are configured for different departments.
When an item in the Purchase Requests list with a department of ‘Sales’ is sent for approval, we will fetch approvers for the department from the ‘Configurations’ list and create a task for each approver.
To do this we create a workflow on the Purchase Requests lists’ Item Modified event as described below.
Action 1
Create a query list action to get an item from Configuration list for the current department.
CAML Query:
O365:
<View><Query><Where><Eq><FieldRef Name=’Department’ /><Value Type=’Text’>##Department##</Value></Eq></Where></Query></View>
Action 2
Create a WF Variable action to store all the approvers.
Value: $usercollection(Get Config for Dept##Approvers)
‘Get Config for Dept’ is the Query list action name(Action 1).
Get Config for Dept##Approvers gets the Approvers from the item returned by the query list action.
$usercollection(Get Config for Dept##Approvers) converts the approvers in to user collection and stores in to WFVariable ‘Approvers’ here.
Action 3: Create a ‘Create Item’ action to create tasks for each user in WF Variable.