Dynamically fill in a SharePoint multi-select person field using Power Automate

Multi-select person fields in SharePoint are quite common, but not straightforward to fill in using Power Automate when you have a variable number of people that could be added. In this post, I’m sharing a way that you can achieve this!

Identifying how to provide the data

To understand how this works, we first need to look at how SharePoint builds up a multi-select person field. For this, add a SharePoint “create item” action with a list that has a multi-select person field defined in it. (You can also use “update item” or “update file properties”) Then, where the multi-select person field is added, enter two dummy inputs by clicking “Add new item” below the first dropdown and providing some data. After entering the data, click the “T” icon in the top right corner of the field to switch to inputting the entire array, and there you’ll see the format of the array that is passed to SharePoint.

Click the “T” button to switch to input the entire array
The data that was entered will be transformed to the right format

This is the format that we need to provide the data in: an array (in between the square brackets) with objects (in between the curly brockets) that specify the “Claims” field, containing an email-address in between double quotes.

Creating an array

The easiest way to create an array in Power Automate is working with an array variable, and the “Append to array” built-in action. So to start, at the beginning of the flow, initialize a variable of type array and provide it with a meaningful name – in my case “CollaboratorsArray” since I will be adding a group of collaborators in an item in a list. Don’t supply an initial value.

Adding the necessary data to the array

Depending on where you’re getting the input email-addresses from, these steps will differ slightly. The basic idea is that for each emailaddress you want to add into the array, you have an “Append to array variable” action that will add an additional object to the array. You can do this with separate actions after each other if you want to combine multiple inputs into one, or you can do this inside a loop to add a list of emails.

In my case, I’m getting the emailaddresses that I want to add from a comma-separated string as a manual input from the flow. Therefore, I will need an “Apply to each” loop and will need to split the input string to get to the list of emailaddresses.

I’m first adding the “Apply to each” action to the flow, and adding the split function as the collection that the loop should iterate over. Afterwards, I add the “Append to array variable” action inside the loop and building up the object that needs to be supplied. So the value of your append action should have the following format:

   "Claims":"your value"

Providing the array to the SharePoint action

Now, all that’s left is to provide the array we built to the SharePoint action in the right location. To make this work, we should add the array into the right field in the “input entire array” option. This is the option where you don’t have the “Add new item” button.

The result will look like the image below. This will correctly fill the multi-select person field in SharePoint, and works when the number of people that are added can be different each time the flow is called!

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

<span>%d</span> bloggers like this: