Power Automate · SharePoint

How to create a list item with a person field using Power Automate

The objective of this blog post is to show multiple ways to create a new SharePoint list item with a person field using a Power Automate flow.

Content

  1. Create item action
    1. Static number of users
    2. List of users defined in a variable
  2. Send an HTTP request to SharePoint
    1. Retrieving user id
  3. References

Create item action

First, let’s use the “Create item action”:

Static number of users

If you have a static number of users to enter in the person field, you can fill each “Claims” field with the email address of a specific user.

You can add more users using the “Add new item” button.

List of users defined in a variable

Now let’s say that the number of users you want to add to your person field depends on the logic of your flow (e.g.: specific conditions, variables).
To do so, you need to have an input with the following format:

[
  {
    "Claims": "BiancaP@M365.OnMicrosoft.com"
  },
  {
    "Claims": "BrianJ@M365.OnMicrosoft.com"
  }
]

To get that specific format, you can use array variables:

Send an HTTP request to SharePoint

But in some cases, the Create item action might not match your requirements (e.g.: use the same flow for multiple sites). So you need to use the Send an HTTP request to SharePoint action.

Retrieving user id

With the Send an HTTP request to SharePoint action, you need to use the user id from the User Information List for each user you want to add in your person field.

The idea would be to use other HTTP requests to get all users ids and then use those ids to fill the the person field:

But not every users are in the User Information list of every SharePoint sites. For example, if a user never got access to a specific site, the user won’t be listed in the User Information list. Hence you won’t be able to retrieve the user id using the action above.

What you can do instead is use the ensure user endpoint of the SharePoint REST API:

With this action, you both create the user in the User Information list and you retrieve its id that you will be able to use to fill the person field using the syntax below (for a multiple selections field):

"InternalColumnNameId": {"results":[15]}

You can add multiple users by adding multiple ids in the “results” array.

If the person field does not allow multiple selections, use the following syntax:

"InternalColumnNameId": 15
Fill the “People” field using user Id from Ensure user action

References