PersonId Field needs to be set

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.

Get the user ID of a SharePoint user

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.

Get the user ID of a SharePoint user

The hidden user list

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.

Get The hidden user list items

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.

Updating the list item people field

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']
Avatar for Pieter Veenstra

By Pieter Veenstra

Business Applications Microsoft MVP working as the Head of Power Platform at Vantage 365. You can contact me using contact@sharepains.com

8 thoughts on “Get the user ID to update a people field in Microsoft SharePoint with Power Automate”
  1. 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

    1. 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.

  2. 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?

    1. 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

  3. 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.

  4. Hi Pieter,
    just came across your great post.
    I am looking for the other way round and hope you can help.

    In my list I have a PERSON column. There 1 person is selected and stored.
    Now I want to lookup the user-id, first name, last name for each person in this list and store it in separate fields for each record.

    I tried myself but without success.

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

Discover more from SharePains by Microsoft MVP Pieter Veenstra

Subscribe now to keep reading and get access to the full archive.

Continue reading