Any tips on how to format JSON to write to a People column?
I am copying columns from one list to another using Flow but am unable to copy a people column.
I am able to use Create item to write to a people column using email claims but not via the REST API.
I have tried passing a claims array:
'PeopleColumn:'
[
{
'Claims': 'i:0#.f|membership|email@company.com'
}
]
But no results:
PeopleColumnId = null
PeopleColumnStringId = null
I have seen examples using SharePoint UserIds - use the GetbyEmail to resolve the Id but the people in the source list are not SharePoint users, ie: they have not browsed the site. They are valid accounts that SharePoint is able to resolve and Create items is able to convert but not REST.
I tried writing to the Hidden Id column:
'PeopleColumnId': {
'__metadata': {
'type': 'Collection(Edm.Int32)'
},
'results': [
11
]
},
Even tried using the Office 365 Users Action, no luck.
Am I missing something in the JSON body syntax?
Is this scenario only possible via Create items?
Solved! Go to Solution.
Thanks for the reply, Bof.
In this case, the users have not browsed the SharePoint site so they won't be returned by the siteusers API call.
And we don't really want to add them to the siteusers list, we just want a valid id that SharePoint can resolve.
As they are in Active Directory we can POST to /ensureusers('email') which returns a user ID (if they are in AD)
Add that user ID to an array, post that array in the REST call and they will appear in the multiselect people column.
HTTP call to SharePoint to generate a user id for non-site users, email is username@domain.com
Add the user ID to the array and Post the array. Make sure to add "Id" to the name of the people column
This approach allows you to use dynamic variables for your site and list when copying multivalue people columns.
Hi @Evervescent :
Firstly,let me explain why you encountered this problem:
The key is that you need to update the personnel column via HTTP request using "Id".
Secondly,you could find all the site users and users id with this request:
/_api/web/siteusers
I've made a test for your refrence:
1\There is a person column named 'Person1'(do not allow multiple selelctions) in my SharePoint List 'Safety Issue'.
2\My Flow
I assume that I want to update the value of the person1 field of the first item to a user whose email address is "bof@xxx"
I think this link will help you a lot:
How to update “Person or Group” column in SharePoint List using REST API
Best Regards,
Bof
Thanks for the reply, Bof.
In this case, the users have not browsed the SharePoint site so they won't be returned by the siteusers API call.
And we don't really want to add them to the siteusers list, we just want a valid id that SharePoint can resolve.
As they are in Active Directory we can POST to /ensureusers('email') which returns a user ID (if they are in AD)
Add that user ID to an array, post that array in the REST call and they will appear in the multiselect people column.
HTTP call to SharePoint to generate a user id for non-site users, email is username@domain.com
Add the user ID to the array and Post the array. Make sure to add "Id" to the name of the people column
This approach allows you to use dynamic variables for your site and list when copying multivalue people columns.
Check out new user group experience and if you are a leader please create your group
See the latest Power Automate innovations, updates, and demos from the Microsoft Business Applications Launch Event.