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!

View solution in original post

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?

View solution in original post

Helpful resources

Announcements
Community Connections 768x460.jpg

Community & How To Videos

Check out the new Power Platform Community Connections gallery!

User Group Leader Meeting January 768x460.png

Calling all User Group Leaders!

Don't miss the User Group Leader meetings on January, 24th & 25th, 2022.

Top Solution Authors
Top Kudoed Authors
Users online (1,970)