Site icon @WonderLaura

Flow Update Multi-Select Column

Advertisements

When building flows in Power Automate, there’s a trick when it comes to updating a field where you can select multiple items.

This applies to:

Especially if the field is required in SharePoint, flow will insist that you populate it with a value, even if that record already has one.  In this post, I’ll show you how to get around this issue, no matter the column type.

In this very simple example, I have a document library full of company policies.  When a file is modified, it goes through an approval process and then the file’s metadata (columns) need to be changed.  The focus in this post isn’t what is happening in the approval process.

The focus is on the update action…

which applies to the Update Item action (for a SharePoint list item) or the Update file properties action (for a file in a library).

My person column is called “Policy Owners”, and I can have multiple owners per policy.  In a flow, the action looks like this:

The tendency, especially when it’s a required field with a red asterisk next to it, is to just add the dynamic content of itself, just put the same value back in this field.  Not so easy with a multi-select.

This is wrong:

The problem with the above screenshot, is that it will create a loop.  For each policy owner, it will update the file properties and put that policy owner’s name in the field.  The problem is that, for example if I have 2 policy owners, it edits the item twice, and each person’s name is inserted as the policy owner, two separate times, so that the end result is only one person’s name will still be in the field. EVERYONE ELSE IS REMOVED EXCEPT FOR ONE PERSON

Again, this problem is the same for all of the different types of multi-select fields.  The solution is to create an array variable.

1.  At the beginning of the flow, right after the trigger, add an action:  Initialize variable

2.  After initializing the variable, add an action to append to an array variable.

3.  Now the syntax is needed, for what the array needs to consist of.  This will be different for different kinds of fields.  Go ahead and add your action to update item or update file properties, and type some random word in the field, and click the button Switch to input entire array.

4.  Voila, here is the syntax you’ll need.  THE SQUARE BRACKETS ARE NOT NEEDED.  Copy this content to your clipboard.  You do need the curly brackets, but not the square ones on the outside.

5.  Scroll back up to your action called Append to array variable.  Paste this in the Value box.

6.  Now the “xyz” needs to be replaced with your dynamic content.  Delete it, and select your field from the dynamic content panel.  A loop will be created, which is fine.  Notice that the field is called “claims” so the policy owner claims is what I select.  Other types of fields may have something like Id or Value, but a person field has “claims”.  Now, for each policy owner, it will add that person to the array, so then you’ll have one big array with everyone in it.

7.  In the Update item or Update file properties action, go back to your field, in my case it’s “Policy owners”, and insert the array variable.  Be sure that the toggle is still set to “switch to input entire array” (from step 3).

The end result is that the value is correctly placed back into the multi-select field.  And you can use this append to an array concept to add more people to the list of policy owners if you needed to do something fancy like that.

Check out my advanced Power Automate (flow) class, self-paced online!

BONUS:

If you need to send an email to, say, all of the policy owners, you would append to a string variable, not an array, and you would use their email address and a semicolon.  Then that variable could be used in the “To” box of the email.


Exit mobile version