Trick to update people picker field with allow multiple option from MS Flow

I faced an issue recently which was kind of an oversight when I look back now. However, there is one small trick which I learned or noticed which can save someone some time and a bit of frustration if you don’t see that small option. So, let me share that with you today. But first, lets set up the context to reproduce the problem.

I created a simple custom list. Add a people picker column with these two configurations:

      1. Make the field required
      2. Allow multiple selections
Select allow multiple selections in people picker
Select allow multiple selections in people picker

Add a choice column called Status with just 2 options

      1. Submitted
      2. Completed
Add a choice field
Add a choice field with Submitted as default option

Now, lets create a new item. Ensure that you add multiple users in the people picker field(Users).

Create a list item
Creating a List Item

Below image shows how the list looks like after the item has been added. We can see 3 people are added to the people picker field and Status is set to Submitted by default.

List after adding a list item
List after adding a list item

Now, lets create a flow which will set the status to Completed. Pretty simple requirement. However, we need to remember that the People picker is a required field. So, we need to set a value to this field.

Create a Flow
Create an instant MS Flow

Here, we can see that if the people picker field is left empty, it gives an error.

Required Field Error
Required Field Error

So, here I have added a get item which will retrieve all the values for the User field. In this case it has 3 items. If I try to set the claims to the claims of the get item, Flow automatically puts a loop around this activity. So, for each of the 3 items, we update the claims.

Set the User claims from Get activity
Set the User claims from Get activity

But this is the problem. Every time, we set the claims, it replaces the previous value, it does not append. If we need to manually append, we have to construct a json object with each claims value. However, there is a simpler way. This is what I wanted to share with you.

After running the flow
Only single value is retained after running the flow

Solution / Trick: There is small button next to the User Claims field. If you hover on it, it says ‘Switch to input entire array’. If you click on it, it changes it’s icon and we can input the entire array.

Little Button next to multi select field
Little button next to multi select field

Changes to this..

After clicking on the button
After clicking on the button

In this mode, we can take the value which we got from the get item (which contains all 3 items) and set it in the update item. Now, it doesn’t create the loop around it.

Now we can select the array of claims
Now we can select the array of claims without a loop

Thats it! Let me know if you found this helpful or interesting. Or what you are interested in reading about. Cheers!

SharePoint Framework Provision Assets

SharePoint Framework Provision Assets

Today, lets take up the topic ‘SharePoint Framework provision assets’. Basically I am referring to the basic building blocks of SharePoint such as:

  1. Create site columns
  2. Site content type
  3. Use SharePoint Framework – Provision List (Create List)

Continue reading “SharePoint Framework Provision Assets”