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

Announcements

News and Announcements icon
Community site session details

Community site session details

Session Id :
Power Platform Community / Forums / Power Apps / Looping over Collectio...
Power Apps
Answered

Looping over Collection records

(1) ShareShare
ReportReport
Posted on by 18

Hi,
I'm currently stuck trying to loop over records stored in a collection.

My aim is to call my Power Automate flow for each row.

My collection consists of five columns (Event Name, Name, Start Date, End Date, Telephone) and I need to loop for each row, inside the loop I need to call my Power Automate flow.
I have managed this with a singular record using the ForAll function which loops the correct amount of times but only uses the most recent row in the collection when it calls the Power Automate flow, causing duplication.  

Any help with this would be much appreciated!

Categories:
  • Bilakanti Profile Picture
    1,226 on at

    @Fulljames ,

     

    I have replicated your requirement and it's working fine for me. I have on collection with 5 records and I executed flow for each record and flow ran successfully 5 times with 5 different outputs.
    Screenshots below.

    Bilakanti_0-1615895232880.pngBilakanti_1-1615895249955.pngBilakanti_2-1615895272869.png

     

  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Fulljames 

    What is the formula you are using?  If you say that you are only getting the most recent row in the collection, then you are referencing your collection improperly.  Is there a particular need for a collection?  Is this coming from a Gallery or other source?

  • Fulljames Profile Picture
    18 on at

    Hi @RandyHayes ,
    The data is being entered into a collection via date pickers and textboxes.
    I've been referencing my collection like so:

    ForAll(FormResponses1,
    If(Connection.Connected, OfflineEventDoc.Run(Email_txt.Text, Name_txt.Text,"<!DOCTYPE html>
    <html>
    <head>
    <title>Event Doc</title>
    </head>
    <body>
    <p>
    
    Event Name: "& EventName_txt.Text &"<br><br>
    
    Start Date: "& StartDate_pkr. &"<br><br>
    End Date: "& EndDate_pkr. &"<br><br>
    
    Name: "& Name_txt.Text &"<br><br>
    Telephone Number: "& Tel_txt.Text &"<br><br>
    
    </p>
    </body>
    </html>
    ")))
  • RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Fulljames 

    How and what are you putting into this collection?

    You are referencing controls in your formula (i.e. Email_txt.Text, Tel_txt.Text, etc.) These are going to reference the controls in your app...nothing from your collection.

  • Fulljames Profile Picture
    18 on at

    @RandyHayes 
    I load data into the collection on an OnClick function like so:

    If( Connection.Connected, PUREMcLarenEventWaiver.Run(Email_txt.Text, PrintName_txt.Text,"<!DOCTYPE html>
    <html>
    <head>
    <title>Event Doc</title>
    </head>
    <body>
    <p>
    Event Name: "& EventName_txt.Text &"<br><br>
    Start Date: "& StartDate_pkr. &"<br><br>
    End Date: "& EndDate_pkr. &"<br><br>
    Name: "& Name_txt.Text &"<br><br>
    Telephone Number: "& Tel_txt.Text &"<br><br>
    </p>
    </body>
    </html>
    "), 
    Collect(FormResponses1, {EventName: EventName_txt, StartDate: StartDate_pkr, EndDate: EndDate_pkr, Name: Name_txt, TelephoneNumber: Tel_txt}); 
    SaveData(FormResponses1, "LocalSavedItems1"));

      

    How would I go about correctly referencing the items within the collection?

  • Verified answer
    RandyHayes Profile Picture
    76,299 Super User 2024 Season 1 on at

    @Fulljames 

    Okay...so if you are collecting EventName_txt for example, in your collection (which is a control...not a value) for the EventName column, then you need to reference that in your formula.

    That is why you are getting the screen values and not what is in the collection...because you are not referencing the value in the collection.

     

    So, first, your collect statement line in the formula you have should be this:

    Collect(FormResponses1, 
     {EventName: EventName_txt.Text, 
     StartDate: StartDate_pkr.Text, 
     EndDate: EndDate_pkr.Text, 
     Name: Name_txt.Text, 
     TelephoneNumber: Tel_txt.Text
     }
    ); 

     

    And your looping formula this:

    If(Connection.Connected, 
     ForAll(FormResponses1,
     OfflineEventDoc.Run(Email_txt.Text, Name_txt.Text,
     "<!DOCTYPE html>
     <html>
     <head>
     <title>Event Doc</title>
     </head>
     <body>
     <p>
     Event Name: " & EventName & "<br><br>
    
     Start Date: " & Text(StartDate, ShortDate) & "<br><br>
     End Date: " & Text(EndDate, ShortDate) &"<br><br>
    
     Name: "& Name &"<br><br>
     Telephone Number: "& TelephoneNumber &"<br><br>
    
     </p>
     </body>
     </html>
     ")
     )
    )

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

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
11manish Profile Picture

11manish 393 Super User 2026 Season 2

#2
Mohsin Ali Profile Picture

Mohsin Ali 328

#3
WarrenBelz Profile Picture

WarrenBelz 278 Most Valuable Professional

Last 30 days Overall leaderboard