Introduction
In this article, we will learn how to update multi-values with the people picker field in Power Automate or MS flow. Updating a multi-value people picker field in MS Flow or Power Automate is a little tricky, and recently a friend came to me for help on this. After lots of trial and error, I was finally able to manage to update the multi-value people picker field. Let us see how to achieve this.
Objectives
- Find an Office 365 group ID associated with the site.
- Find a list of all members of this office 365 group.
- Add these members to a list column (people picker with multi-value)
Let's start by building our flow.
For demo purposes, we will use manual trigger action.
Step 1. Add "Manually trigger a flow" as a trigger point.
Step 2. Add Initialize a Variable action, select type as Array
Step 3. The next thing we have to do is get the Office 365 group ID associated with the site.
To get a group ID of the site, we can use the endpoint '_api/site/', which has GroupId as properties, this is the GroupID of the Office 365 group.
Add the action, "Send an HTTP request to SharePoint", and select the parameters below.
Though I have selected the site address directly from the dropdown, you can always use dynamic content or expression (if you are getting the site URL from somewhere else).
in Uri, I am directly using _api/site/GroupId so that I don't get any other site properties (which I don't require in this case).
Step 4. The next thing we will do is use Parse JSON action so that the response of the above action can be directly used in the next steps from a dynamic content window.
Use the below sample JSON as payload in 'Use sample payload to generate schema'.
{
"d": {
"GroupId": "8db58c1c-22-232-adde-2332"
}
}
Step 5. Now that we have the GroupId of Office 365 group, we will query group members by using the action 'List group members'.
Step 6. The above action will return an array of group members so we will have to loop through each member and generate the required array to pass to the people picker column.
Add 'Apply to each' action, select an output of the above action in 'Select an output from the previous step'
Step 7. Add a compose action and the below JSON string, you can always replace @{items('Apply_to_each')?['mail']} by selecting the dynamic content mail property from 'List group members'. As you can see in the screenshot below, (with marked as 7), I have used a dynamic content selector to add mail property.
{
"Claims": "i:0#.f|membership|@{items('Apply_to_each')?['mail']}",
"Email": "@{items('Apply_to_each')?['mail']}"
}
Step 8. Append this compose method to output to Array. Select the 'Append to Array variable' action and select Managers as the Name, and 'Output' as the value.
Step 9. Now we have the required object to update the people and group column. Now let's use the create item action and select values accordingly.
For the Managers column, (which is a people picker with multi-value allowed), click on the icon marked with a green arrow in the below screenshot. This will switch to input for the entire array. Select the manager's variable here.
Save the workflow and test it. If everything goes well, it should run successfully.
Let's check the list item.
We should see that multiple users are updated in the Manager field.
Conclusion
Updating the people picker column with dynamic values is a little tricky. This article will give you the basic idea of how to form JSON which is required to update the PeoplePicker column if our user's value is not coming directly from SharePoint.
Hope you enjoyed reading...Happy flowing..!!!