Skip to content

Let's POWER Automate

From no-code to low-code

Menu
  • Expressions
  • Filters
  • General
  • Problems
  • Triggers
  • Application specific solutions
    • Excel
    • Forms
    • Planner
    • Outlook
    • SharePoint
    • Teams
  • Resources
Menu

Get items for each user in multiple people picker field (Power Automate)

Posted on September 5, 2021September 5, 2021 by Tom

“Is there a way in Power Automate to split emails from a multiple people picker field to have a single email per user for all of the items in which they are included as an owner?”


Following a question from the original article to Send one email per user with multiple SharePoint items, what if the column is not a single people picker? What if the column allows selection of multiple users? If you have more than 1 user assigned per item? You probably still want to send only one email per user, even if they share the item with others.

Get user emails from the items

Once you switch the people picker column to multiple selection, its structure will change. It won’t be an object with the user anymore, now it’ll be an array of objects (=users). And as such you can’t get the email addresses as easily using the ‘Select’ action. You’ll have to use a less efficient way with double loops.

But first, initialise a new array variable, e.g. var_emailsArray. In that variable you’ll store each email separately. Once you initialise the variable, add ‘Apply to each’ to loop through all the items provided by the ‘Get items’. In that loop add another ‘Apply to each’ to loop through users in the people picker field. And in that loop place the ‘Append to array variable’ to store their email address.

Power Automate user items multiple people picker

Note: my column is called ‘SendTo’, your column will have most probably a different name.

At the end of the loop you’ll have a variable that’ll contain all the email addresses as separate items. Process it with the union(…) expression to keep only the unique values = unique emails.

union(variables('var_emailsArray'),variables('var_emailsArray'))

Filter the items for each user

The other difference from the original flow is in the ‘Filter array’ action. As already said, the people picker column in each item will contain an array of users. Therefore, you can’t simply filter by the user email. You must check the whole array of objects if one of them contains the email address. The easiest way is to convert the array into a string with the string(…) expression, which will allow you to use the ‘contains’ operator.

string(item()?['SendTo'])
Power Automate user items multiple people picker

From that point on you can continue with the original flow – build an HTML table and send the email.

Full flow diagram

I noticed the screenshot is missing a trigger, but it’s a ‘Recurrence’ trigger as in all reminder flows.

Power Automate user items multiple people picker

Summary

Once you switch from the single user to multiple people picker in SharePoint items, the Power Automate flows get more complicated. You don’t have a single object where you can easily access the email, you’ll get an array. And since it’s an array, you’ll have to loop through all the items, and for each item loop through the users. Once you’ve got them in a variable it’s easy to remove duplicates and filter the items with the little string(…) workaround.


Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

12 thoughts on “Get items for each user in multiple people picker field (Power Automate)”

  1. Raj says:
    November 16, 2021 at 6:13 pm

    great.. Thanks you for sharing this post.
    I have a question though. In my SharePoint list, instead of a people or group field, i had to create a single line to text field that holds multiple email addresses with “;” delimiter as the values are coming from a different list via a lookup. What’s the best way to incorporate that in this flow. Essentially, i need to split the emails in that text field and then use those emails to send a list of items based on filter criteria. Thanks in advance for you help.

    Reply
    1. Tom says:
      November 28, 2021 at 10:54 pm

      Hello Raj,
      if you already have the email addresses, you can split them using the split(…) expression: split(, ‘;’). Loop through the result of the split(…), append all the values in the array variable, and from then on continue as in the flow.

      Reply
  2. Berihun Addis says:
    November 28, 2021 at 8:18 pm

    In my scenario I have 7 branch office. and i want to automate Clearance request system. as well as i have 6 approves like( Line Manager,store,IT,Facility,Finance and HR).
    when Item is created in share point the flow must send approval request based on requester Location means that if the requester Location is From “X” location all approvers who are in “X” Location should get the requester approval. if the requester Location is From “Y” location all approvers who are in “Y” Location should get the requester approval. How can I do this in Power Authomate?

    Reply
    1. Tom says:
      December 6, 2021 at 12:51 pm

      Hello Berihun,
      you just need a list with approvers, and every time you need an approver take him from the list based on the parameters, these articles should help:
      https://tomriha.com/lookup-to-sharepoint-list-with-approvers-in-power-automate/
      https://tomriha.com/how-to-combine-multiple-filters-in-get-items-filter-query-power-automate/

      Reply
  3. Newbie says:
    December 20, 2021 at 10:52 pm

    Hi, I get the following error: Flow save failed with code ‘InvalidTemplate’ and message ‘The template validation failed: ‘The inputs of template action ‘Filter_array’ at line ‘1 and column ‘2813’ is invalid. Action ‘Apply_to_each_2’ must be a parent ‘foreach’ scope of action ‘Filter_array’ to be referenced by ‘repeatItems’ or ‘items’ functions.’.’. Can you please help

    Reply
    1. Tom says:
      December 30, 2021 at 9:46 am

      Hello Newbie,
      the error message tells you that the ‘Filter array’ action must be inside ‘Apply to each 2’, otherwise it can’t reference the dynamic content you use in the ‘Filter array’.

      Reply
  4. New says:
    December 20, 2021 at 11:39 pm

    Hi Tom, I get this error now

    The ‘inputs.parameters’ of workflow operation ‘Send_an_email_(V2)’ of type ‘OpenApiConnection’ is not valid. Error details: Input parameter ’emailMessage/To’ is required to be of type ‘String/email’. The source type/format ‘Array’ of the value ‘[“houahega@hoauehga.com”]’ is not convertible to type/format ‘String/email’.

    Reply
    1. Tom says:
      December 30, 2021 at 9:49 am

      Hello New,
      this error is telling you that you can’t use an array – defined by the [ and ] as an email recipient, you must extract the value from the array. The flow is using ‘Apply to each’ to process all the arrays, you’re probably not using the currently processed item from the loop as the recipient but the whole array.

      Reply
  5. Boobesh says:
    February 24, 2022 at 3:41 pm

    When we trying to do bulk update the appending array is not feasible as its appending all the Users from PeopleColumn and sending an email . Example: Each Item has 2 approvers. When doing bulk update like closing tickets, all the approvers are appended to array and in every email all the approvers are added in CC.

    Can you have the steps to avoid that.

    Reply
    1. Tom says:
      February 27, 2022 at 7:47 pm

      Hello Boobesh,
      I’m sorry but I don’t understand what you’re trying to achieve. This blog post is about sending emails to users, it’s not about updating users.
      If you have some array that contains more users then it should then you probably don’t empty it (set value to ‘null’ expression) at the beginning of each loop.

      Reply
  6. Alberto says:
    May 12, 2022 at 2:09 am

    Hey Tom,

    Would it be possible to use this approach with a few changes to identify if the email one of the Users within the field (column) is equal to the email of the Last Modified By? If so, do you think I could ask you for some direction on how to proceed?

    (Also, I accidentally posted this same question in one of your other articles. Sorry. I meant to ask this question here.)

    Thanks in advance.

    Reply
    1. Tom says:
      May 17, 2022 at 8:29 am

      Hello Alberto,
      if your goal is just to check if a multiple people picker field contains the Modified By user then I’d use just a ‘Condition’: if contains . Maybe you’ll have to convert the field value to string(…) for the comparison to work.
      string() contains

      Reply

Leave a Reply Cancel reply

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

Now available:

The Ultimate Power Automate expressions cheat sheet
Equip yourself with the tool to translate your thoughts into Power Automate expressions!

Do you struggle with the various expressions, conditions, filters, or HTTP requests available in Power Automate?

I send one email per week with a summary of the new solutions, designed to help even non IT people to automate some of their repetitive tasks.

All subscribers have also access to resources like a SharePoint Filter Query cheat sheet or Date expressions cheat sheet.

Zero spam, unsubscribe anytime.

Hello and welcome!

My name is Tom and I'm a business process automation consultant and Microsoft MVP living in the Czech Republic. I’ve been working with Microsoft technologies for almost 10 years, currently using mainly Power Automate, SharePoint, Teams, and the other M365 tools.

I believe that everyone can automate part of their work with the Power Automate platform. You can achieve a lot by "clicking" the flows in the designer, but you can achieve much more if you add a bit of coding knowledge. And that's what this blog is about.

To make the step from no-code Power Automate flows to low-code flows: using basic coding knowledge to build more complex yet more efficient flows to automate more of your daily tasks.

  • Format results of date calculation in SharePoint columnJune 29, 2022
  • Why is your Power Automate flow creating duplicatesJune 26, 2022
  • How to create a unique identifier in your Power Automate flowJune 22, 2022
  • How to assign custom SharePoint permission level with Power AutomateJune 19, 2022
  • Remove permissions from a specific SharePoint user with Power AutomateJune 15, 2022

Power Automate blogs worth visiting

Damien Bird
Dennis (Expiscornovus)
Paul Murana

© 2022 Let's POWER Automate | Powered by Superbs Personal Blog theme