Let's start by building our flow.
For demo purposes, we will use manual trigger action.
Add "Manually trigger a flow" as a trigger point.
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'.
{
"d": {
"GroupId": "8db58c1c-22-232-adde-2332"
}
}
Step 5
Now that we have 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 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.
{
"Claims": "i:0#.f|membership|@{items('Apply_to_each')?['mail']}",
"Email": "@{items('Apply_to_each')?['mail']}"
}
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.
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.
Save workflow and test it. If everything goes well, it should run successfully.
Let's check in 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..!!!
P.S - This article was originally published at this
link