cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
RussellGove
Kudo Kingpin
Kudo Kingpin

how to extract email address from a sharepoint person or group column that allows multiple selection

Hi, I have a SharePoint list named 'Systems' it has a Titlle field and a field called 'SustemMaintainer'.  'SystemMaintaiiner is  a 'Person Or Group' columns that allows multiple selections and people only.

 

In my flow I got the correct row by calling getItems and filtering based on the title column. so I have an array with one row, and that row has an a  column that contains an array of people columns:

[
    {
        "Claims": "i:0#.f|membership|russell.gove@xx.com",
        "DisplayName": "Gove, Russell",
        "Email": "Russell.xx@xx.com",
        "Picture": "https://xx.sharepoint.com/sites/GLMasterData/_layouts/15/UserPhoto.aspx?Size=L&AccountName=Russell.Gove@tronox.com",
        "Department": "Infrastructure Services",
        "JobTitle": "Sr SharePoint Architect"
    },
    {
        "Claims": "i:0#.f|membership|xx.xx@xx.com",
        "DisplayName": "xx, xx",
        "Email": "John.xx@xx.com",
        "Picture": "https://xx.sharepoint.com/sites/GLMasterData/_layouts/15/UserPhoto.aspx?Size=L&AccountName=John.Njoroge@tronox.com",
        "Department": "CFO Staff",
        "JobTitle": "Manager Accounting Analysis"
    }
]

How do I go about sending an email to the  Email addresses in that array.

The expression 

 

body('getItems')?['Value']?[0]?['SystemMaintainer']]

gets me the list of objects,  But how do i extract the email addresses from thos objects in a format thats sutable for sending an email?

33 REPLIES 33

@ScottShearer please I trying to use the emails to send approvals also and I have been stuck on this for about 2days now. I tried using your method and it works well but on inserting the variable in the “To” section of sending an email, it joins both email addresses together and that throws the error that the user doesn’t exist.

 

Can you help suggest how I can go about this so that it is able to separate the email as 

 

“email1; email2”  Instead of “email1email2”

@Ade-O 

It would be best if you create a new thread/post and include detailed screen shots of your Flow.  If you @ mention me I will respond.

 

 

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Scott

Hi @faustocapellanj 

 

Your approach has worked perfectly for me in workflows where my trigger is "when an item is created" or "when an item is modified". However, I also want to use it in a Reminders workflow, where the trigger is of "Schedule/Recurrence".

 

After using the same logic, I keep getting this error in my Select. I understand this is probably because in this scenario, the "Get Items 2" is getting items for each item from the first "Get Items", hence it automatically changed "Get Items 2" to "Apply to each 3". But I can't crack a solution or workaround to deal with this.

 

flow run failed.jpg

 

Any help would be highly appreciated. If you want me to clarify anything please let me know. Thanks!

REally good explanation! Helped me a lot!

Hi, Im trying to achieve the exact same. However when I use the first() function in the expression it only returns the first array and hence only the first email address for the person assigned to the field/column. Is it possible to do the same as you describe but extract all users emails addresses??

CarlHRVA
Continued Contributor
Continued Contributor

Hi Matt,

The solution that worked for me was the one @ScottShearer provided on the first page where you use an Apply to Each action to loop through the values in the column and store them in a variable.  

MattWearmouth
Frequent Visitor

Im not sure where the apply for each should go. I have spent a good few hours today trying to get this to work and failed. If anyone is available to give me a call to help that would be great! 

MattWearmouth_0-1643825647906.png

 

My attempt to use a apply to each got me somewhere but the outputs were empty...

 

CarlHRVA
Continued Contributor
Continued Contributor

Let me see if I can explain.

  1. First you initialize an array variable. From your screenshot it looks like you have one called Users Array. In my screenshot it's called varEmail ✔️
  2. Then you use the "Get items" action to get the items from your list, where the multi-select person or group column exists. We both have this action. ✔️
  3. The easiest way to create the "Apply to Each" action next is to use a "Set Variable" action to set the value to equal the multi-select people column from the "Get Items" action before. When you choose the Multi-select person or group column as the value of your array variable, it will automatically create the apply to each action for you.
  4. Move all of your other variables/actions inside of that same apply to each action.
    CarlHRVA_0-1643827320344.png

     

CarlHRVA
Continued Contributor
Continued Contributor

CarlHRVA_1-1643827413986.png

For clarity, here is what it looks like before you choose your multi-select column. After you select it, in my case "Assigned to", it will generate the apply to each for you

Had a little trouble using this solution, kept receiving error:

"The 'from' property value in the 'select' action inputs is of type 'Object'. The value must be an array."

 

Amended 'From' to outputs('Get_items')?['body/value']

And 'Map' to item()?['RequestManager']?['Email']

 

This fixed it, provided an array of all emails held within my 'RequestManager' person field.

Still not getting this work work. Getting this error for the 'Select' operation

MattWearmouth_0-1644435999667.png

 

MattWearmouth_1-1644436009757.png

 

 

Resolved! 

MattWearmouth_0-1644449659360.png

items('Apply_to_each')?['actionWith0']

 

item()?['Email']"}]

 

Jolinchang
Regular Visitor

Hi  @faustocapellanj good day

when "select" named "get mail" step, shows error as below after run, but the output from "get items" is not Null.

"The 'from' property value in the 'select' action inputs is of type 'Null'. The value must be an array."

any ideas, thanks so much

 

Jolinchang_2-1649328921051.png

 

Jolinchang_1-1649328767610.png

Jolinchang_3-1649329053430.png

 

 

 

This works for me but with one issue. Its only grabbing the first two emails from my sharepoint column? 

 

How can I make it grab all of them? A loop wont work for my use case. I am writing to an excel row which I'm using to add members to a group via powershell.

Helpful resources

Announcements
Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

May UG Leader Call Carousel 768x460.png

June User Group Leader Call

Join us on June 28 for our monthly User Group leader call!

MPA Virtual Workshop Carousel 768x460.png

Register for a Free Workshop

Learn to digitize and optimize business processes and connect all your applications to share data in real time.

Power Automate Designer Feedback_carousel.jpg

Help make Flow Design easier

Are you new to designing flows? What is your biggest struggle with Power Automate Designer? Help us make it more user friendly!

Users online (1,493)