web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Automate / looping through items ...
Power Automate
Unanswered

looping through items in a List

(0) ShareShare
ReportReport
Posted on by

looping through items in a List but instead of sending out an email for each list item that meets the condition, collect up the list item data and send out one email at the end. So if a list has 5 items that meet the condition, don't send out 5 emails, send 1 email that says "you have the following 5 items to work on".

 

Categories:
I have the same question (0)
  • ryleybauer Profile Picture
    327 on at

    Use the "Initialize Variable" step at the beginning to create an Array. You'll probably have to create one for each of your conditions unless you reset it mid-flow. 

     

    Each time you hit the condition, instead of an email step, use the "Append to array" step. 

     

    Then at the end, send your email with the respective array in the body. 
    If you want, you encapsulate it in a "String()" function and also use a "sub()" function to replace quotes and square brackets if you don't like the array formatting.

     

    Please mark as solution if this helps your issue. 

  • Verified answer
    David- Profile Picture
    1,254 on at

    I just set something like this up today. I needed to go through a task list of assignments to our attorneys and send them a summary of outstanding tasks each Friday afternoon. This is how I built it:

    1. Start action Occurrence each Friday
    2. Initialize variable of array type named Emails with the value of: e.g., [ "email1@company.com","email2@company.com", "email3@company.com" ]
    3. Initialize variable of type integer named Count with an initial value of 0 (zero)
    4. Compose action with the input being the output of step 2 above (I probably didn't need this, but it works)
    5. Apply to each action with the output of the compose action in step 4
    6. Get items action set up for the list where you want to pull data
      • The filter will be the people field in your list that you want to pull items for along with any other criteria.
      • For me, the filter is: AssignedTo/EMail eq 'Current item' and PercentComplete eq 0
      • Note: Current item is from in dynamic content under apply to each
    7. Set variable action for the Results variable with the expression length(outputs('Get_items')?['body/value']) as the value
    8. Condition action where Results variable is greater than 0 (zero)
    9. If yes the value being the output of the above Get items action and configure for the fields you want to return: 
      David_0-1656444701280.png

       

    10. Create html table action from the output of the above Select
    11. Send an email (V2) action with the output of the Create html table action.

    It is hard to read, but the workflow looks like this:

    David_1-1656445045622.png

     

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Forum hierarchy changes are complete!

In our never-ending quest to improve we are simplifying the forum hierarchy…

Ajay Kumar Gannamaneni – Community Spotlight

We are honored to recognize Ajay Kumar Gannamaneni as our Community Spotlight for December…

Leaderboard > Power Automate

#1
Michael E. Gernaey Profile Picture

Michael E. Gernaey 522 Super User 2025 Season 2

#2
Tomac Profile Picture

Tomac 364 Moderator

#3
abm abm Profile Picture

abm abm 243 Most Valuable Professional

Last 30 days Overall leaderboard