A While back I wrote a post about Updating People Fields in SharePoint using Flow. On of the requirement is to get the user ID of the user that you want to set a field to.
How do we get this field ID?
We will need to have the Id to set a people field. Note from my previous post that you want to set a field PersonID if your field is called Person.
You might remember the hidden user list post by Thomas Zimmergren.
You can get the items from the hidden user list in two different ways. Either use a REST API call or just use the Get Items action in flow. Whichever has your preference.
I’m now using the Get items action.
To Update the list item I’m using the REST API call. Why? Simply because I want my flows to be more generic. I need to be able to copy Flows between environments. This also means that I need to be able to soft copy rather than hard copy the SharePoint site url.
The Get Items will give me an array of 1 users. I queried by email address and I know for sure that I will only get one item back. To make sure that I don’t get one of those annoying apply to each steps added I’m including a first function which will give me the first item in the array of users. The full expression for this is:
first(body('Get_items')?['value'])?['Id']
Last week Shane Young asked me about calculating the Sum for a SharePoint column in…
In Power Apps when you do a Patch to create a new item or to…
Getting started with adaptive cards can be difficult. In this post i have written some…
In this post I will look at how to create PDF documents from data. Use…
We all know this problem, you have a nested array in Power Automate but how…
Yesterday one of my clients showed me an issues where the Advanced settings didn't load.…
View Comments
Hi Thanks for this useful post.. But this means that user at some point was or is part of the site.. But what if user has never visited or been added to site.. I have this scenario where it is not guaranteed that user is or was part of site
Hi Sumit,
The problem is that you would need to have an ID to set the user. The user will have an ID as soon as it has been used in a people field. So not when the user has been on the site.
I just tried manually in SharePoint to set a field to an unknown user and that added the entry in the hidden user list.
Hi,
Thank you for this post. I have same question as above. How to add a user field to a List using SharePoint Http service, if the user has never been added to the site collection users or group?
I don't think that there is a way to do that unless you can add a new entry to the hidden user list uisng the api. If I remember correctly then this has been disabled
You can do a post to /_api/web/ensureuser('emailhere/or name, if it's AD unique') and it'll create the entry if it's not on the hidden list. The result is a User object with all the properties you might need.
Hi Tiago,
Thank you for your comment. That will indeed also work.