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 / Loop through 2 collect...
Power Apps
Answered

Loop through 2 collections using ForAll to Patch a record

(0) ShareShare
ReportReport
Posted on by 75

Hi I would like to know if it is possibel to loop through two collections at once then Patch the result. For example I have tried the follwoing but have had no luck.

 

ForAll(Attachments.Attachments As Document && col_IDs As varPatchedItem,

Patch( 'Data Source', Defaults('Data Source'), {Title: Document.Name, ItemID: varPatchedItem}))

 

Any help would be greatly appreciated!

 

 

Categories:
I have the same question (0)
  • PowerAddict Profile Picture
    7,316 Most Valuable Professional on at

    What are you trying to achieve here? Do you want to loop through every single record in col_ID for each attachment? 

     

    ---
    If you like this reply, please give kudos (Thumbs Up). And if this solves your problem, please mark this reply as a solution by selecting Accept as Solution. This makes it easier for others to find answers to similar questions. 

     

    Thanks!

    Hardit Bhatia

    Microsoft Business Applications MVP

    Microsoft Certified Trainer MCT

    Blog | Twitter | LinkedIn | Facebook | YouTube  |  Email

  • NicolleAbrahams Profile Picture
    75 on at

    No I'd like to loop throught them simultaneously i.e: For loop 1 print the first value in each collection, for the 2nd loop use the 2nd value in each collection, for the 3rd loop use the 3rd value in each collection and so on.

  • Verified answer
    WarrenBelz Profile Picture
    155,463 Most Valuable Professional on at

    Hi @NicolleAbrahams ,

    Note that the last .Value may be different depending on the name of the field containing the ItemID in colIDs. Also I am assuming there are enough ItemIDs for the number of attachments.

    Patch(
     'Data Source',
     ForAll(
     Sequence(
     CountRows(Attachments.Attachments)
     ),
     {
     Title: 
     Index(
     Attachments.Attachments,
     Value
     ).Name,
     ItemID: 
     Index(
     colIDs,
     Value
     ).Value
     }
     )
    )

     

    Please click Accept as solution if my post helped you solve your issue. This will help others find it more readily. It also closes the item. If the content was useful in other ways, please consider giving it Thumbs Up.

    MVP (Business Applications)   Visit my blog Practical Power Apps

  • NicolleAbrahams Profile Picture
    75 on at

    This worked thank you so much!

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Users!

Kudos to our 2025 Community Spotlight Honorees

Congratulations to our 2025 community superstars!

Congratulations to the April Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Vish WR Profile Picture

Vish WR 610

#2
Haque Profile Picture

Haque 317

#3
WarrenBelz Profile Picture

WarrenBelz 315 Most Valuable Professional

Last 30 days Overall leaderboard