PersonId Field needs to be set

Get the user ID to update a people field in Microsoft SharePoint with Power Automate

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']

4 thoughts on “Get the user ID to update a people field in Microsoft SharePoint with Power Automate

  1. commented on January 21, 2020 by Sumit Valecha

    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.

  2. commented on May 18, 2020 by kauravin

    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?

    • commented on May 18, 2020 by Pieter Veenstra

      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

Leave a Reply

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

%d bloggers like this: