November 17, 2024

Power Automate and SharePoint work excellently, but I see many people with questions regarding how to fetch multi-select columns in SharePoint. Especially the “Person” columns that are complex objects, making things a bit more tricky.

Parse multi-choice columns in SharePoint

This template provides a full Flow that gets the information from SharePoint and details how to extract multi-select columns. For the sake of example, we’ll be using the “Person” type that is the most complex. 

As always, I’ll provide you already with the template in case you want to explore it. If you want to understand what’s going on, here we go.

The list

Let’s create a simple SharePoint list that contains a column for “People” as below:

Since my tenant only has 1 person (me 💪) I will only fill-in with one email but you can test with multiple without needing to change anything.

Now that we have a sample list, let’s do the template.

The template

To have a real case to test, let’s fetch all unique people for all rows.

The steps are simple:

  1. Fetch all people
  2. For each person, check if the email exists in the array
  3. Add the email to the array if they don’t exist.

Why 2 “Apply to Each”?

Since we have multiple items in the SharePoint list, we need an “Apply to each” action to iterate them. But notice that we defined the column “People” as “Allow Multiple Selections”, so we can have several items on that column per record. So we need to:

  1. For each row
  2. In the row, for each element in the column “People”.

Keep this in mind when you’re building your Flows. For example, you may have nested “Apply to each” action depending on how many elements exist.

I don’t see the properties in the “Dynamic Content.”

Another issue that I see frequently is that sometimes the elements don’t show up in the “dynamic content.” Again, we can solve this, but we need to understand how the “Apply to each” action works.

Here’s an example. I will add another person column with the same structure, but now called “Managers.”

Let’s do the same as before, using the same list. We only want different email addresses, so here’s what we do. We copy and paste the previous action, and we get:

The template won’t contain this part. It’s just to prove a point

Now let’s remove the “People” and add the “Managers.” So far, so good, but now let’s add the email to the “Condition” action. If you can’t see it on the “Dynamic Content,” don’t worry. We can build it ourselves. To do that, we can use the following formula:

items()?['Email']

So what’s happening here? First, we check the current item in the “Apply to Each” action using the item function. It will signal to Power Automate that we want the current item that is being iterated. After that, we indicate that we wish to use the square brackets notation to the “Email” field in that object. Finally, the “?” This shows that the field is optional, meaning that if we can’t find anything, the Flow won’t crash.

Final thoughts

The template is quite simple, but I wanted to show you how to deal with multi-select columns by adding nested “Apply to Each” actions and what we can do if we don’t see the values in the “Dynamic Content” tab. I’ll write a more detailed article about this soon, but I think it’s an excellent overview of the concept.

Have a suggestion of your own or disagree with something I said? Leave a comment or interact on Twitter and be sure to check out other Power Automate-related articles here.

Photo by Eric Prouzet on Unsplash

Manuel Gomes

I have 18 years of experience in automation, project management, and development. In addition to that, I have been writing for this website for over 3 years now, providing readers with valuable insights and information. I hope my expertise allows me to create compelling, informative content that resonates with the audience.

View all posts by Manuel Gomes →

One thought on “Power Automate: Multi-select columns in SharePoint

Leave a Reply

Your email address will not be published. Required fields are marked *

Mastodon