sharepointpower-automatepowerappspowerapps-canvas

Powerapp Canvas app - How to get email addresses of a Sharepoint List Person column?


I have a Sharepoint list that has the columns:

  1. Step (integer starts from 1)

  2. Document (lookup column from a Sharepoint Library)

  3. Type of Task (a Choice column containing Draft, Review)

  4. Users (Person/Group Column that Allow Multiple Selections). Example of the list:

     Step   Document   Type of Task   Users
     1      Doc1       Draft          Smith,John Smith, Mary
     2      Doc1       Review         Smith, Anne
    

In my Powerapp canvas app, how can I get the emails of Document Doc1, Step 1 ie. emails of Smith,John and Smith, Mary, so that I can send an email to this list of people ?

Thank you


Solution

  • SharePoint Person columns are represented in Power Apps as a record with many fields, one of them being "Email" which containes the information you want. So if you are showing the list in a gallery, for example, you can get the e-mail addresses by using an expression such as the one below, which will return the e-mails separated by ;

    Concat(ThisItem.Users, ThisRecord.Email, ";")
    

    For example, if you want to send e-mail to those users inside a gallery, you would use something like

    Office365Outlook.SendEmailV2(
      Concat(ThisItem.Users, ThisRecord.Email, ";"),
      "test subject",
      "test body")
    

    Or if you want to find the e-mails for a specific record, once you fetch the record you can use a similar expression:

    With(
      { record: LookUp(YourSPList, Step = 1 And Document = "Doc1") },
      Concat(record.Users, ThisRecord.Email, ";")
    )
    

    Similar to the previous one, if you want to send an e-mail to those users, the app would have an expression similar to this one:

    Office365Outlook.SendEmailV2(
      With(
        { record: LookUp(YourSPList, Step = 1 And Document = "Doc1") },
        Concat(record.Users, ThisRecord.Email, ";")
      ),
      "test subject",
      "test body")