cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
WebPortal
Post Prodigy
Post Prodigy

Loop trhough users emails

This is my array:

 

 

[
  {
    "User": "9xzcxzczxczxcczxc2cd31d69d51a",
    "Tasks": [
      {
        "title": "Reception, validation and account of local suppliers invoices",
        "dueDate": "2020-11-21T01:25:23Z"
      },
      {
        "title": "Another task",
        "dueDate": "2020-11-21T01:25:23Z"
      }
    ]
  },
  {
    "User": "25e6zxczxczxcxz7027d3c5",
    "Tasks": [
      {
        "title": "Data maintenance of master & controle files in MFG-PRO",
        "dueDate": "2020-11-21T01:25:23Z"
      },
      {
        "title": "Yet another task",
        "dueDate": "2020-11-21T01:25:23Z"
      }
    ]
  }
]

 

 

I need to send an email to each of these 2 users with a list of their respective tasks.

 

So, I'm trying to loop through the users with an "Apply to each" step.

 

WebPortal_0-1605898547616.png

 

But how to

 

  1. Transform the user id to user e-mail
  2. Loop through each task

 

My code above is (obviously wrong), the following:

 

substring(Outputs('User'),0, indexOf(Outputs('User'),'"'))
 
 
2 ACCEPTED SOLUTIONS

Accepted Solutions
fchopo
Super User
Super User

Hello @WebPortal 

You could do something like this:

csvemail.png

 

1) For each item in the array

2) Get the email of the using its id using the expression:

items('apply_to_each')?['User']

3) Create a CSV table using the Tasks array using the following expression:

items('apply_to_each')?['Tasks']

4) Send the email

 

Hope it helps!

Ferran

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!

View solution in original post

Paulie78
Super User
Super User

Why not create a html table instead of CSV and send that to them?

View solution in original post

3 REPLIES 3
fchopo
Super User
Super User

Hello @WebPortal 

You could do something like this:

csvemail.png

 

1) For each item in the array

2) Get the email of the using its id using the expression:

items('apply_to_each')?['User']

3) Create a CSV table using the Tasks array using the following expression:

items('apply_to_each')?['Tasks']

4) Send the email

 

Hope it helps!

Ferran

 

Did I answer your question? Please consider to mark my post as a solution to help others.
Proud to be a Flownaut!
WebPortal
Post Prodigy
Post Prodigy

It worked, thank You!

 

Only the formatting could be improved.. this is how it looks:

 

title,dueDate "Reception, validation and account of local suppliers invoices",2020-11-20T10:00:00Z Data maintenance of master & controle files in MFG-PRO,2020-11-20T10:00:00Z

Paulie78
Super User
Super User

Why not create a html table instead of CSV and send that to them?

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.

New Ideas Forum MPA.jpg

A new place to submit your Ideas for Power Automate

Announcing a new way to share your feedback with the Power Automate Team.

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.

Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022- Season 2 has kicked off!

Users online (2,193)