Update Multi-Values with People Picker Field in Power Automate/Microsoft Flow

In this article, we will learn how to update multi-values with the people picker field in Power Automate or MS flow

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 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
 
Update Multi Values People Picker Field In Power Automate/Microsoft Flow
 
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 parameters as 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 below sample JSON as payload in 'Use sample payload to generate schema'. 
  1. {  
  2.   "d": {  
  3.     "GroupId""8db58c1c-22-232-adde-2332"  
  4.   }  
  5. }  
Update Multi Values People Picker Field In Power Automate/Microsoft Flow
 
Step 5
 
Now that we have GroupId of office 365 group, we will query group members by using the action 'List group members'.
 
Update Multi Values People Picker Field In Power Automate/Microsoft Flow
 
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 people picker column.
 
Add 'Apply to each' action, select an output of above action in 'Select an output from previous step'
 
Step 7 
 
Add a compose action and the below JSON string, you can always replace  @{items('Apply_to_each')?['mail']} by selecting 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. 
  1. {  
  2.   "Claims""i:0#.f|membership|@{items('Apply_to_each')?['mail']}",  
  3.   "Email""@{items('Apply_to_each')?['mail']}"  
  4. }  
Step 8 
 
Append this compose method output to Array. Select 'Append to Array variable' action and select Managers as the Name, and 'output' as the value.
 
Update Multi Values People Picker Field In Power Automate/Microsoft Flow
 
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 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 th entire array. Select the Mangers variable here. 
 
Update Multi Values People Picker Field In Power Automate/Microsoft Flow
 
Save workflow and test it. If everything goes well, it should run successfully.
 
Update Multi Values People Picker Field In Power Automate/Microsoft Flow
 
Let's check in the list item.
 
Update Multi Values People Picker Field In Power Automate/Microsoft Flow
 
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..!!!