Skip to main content

Notifications

Community site session details

Community site session details

Session Id :
Power Apps - Building Power Apps
Answered

Error for patch within for all.

(0) ShareShare
ReportReport
Posted on by 102

Hi

https://www.youtube.com/watch?v=0xZ4fMJbLvk
This video "Select multiple records in a gallery and Patch with the PowerApps ForAll function" was exactly what I was looking for.
However, I have a concern about two consequent patches for datasource and collection. it is minute 24. There are some manipulations done before so collection has column IsChoosen and checkboxes within Gallery change them to True.

the code there is:

 

ForAll(
RenameColumns(Filter(test_coll,IsChoosen),"ID","IID"),Patch(mesra_test,LookUp(mesra_test,ID=IID),{RevisionStatus:"For Deletion"});
Patch(test_coll,LookUp(test_coll,ID=IID),{RevisionStatus:"For Deletion"}))


Can you advise how to break the pipeline if first patch is error in this case.

as it was mentioned, Source of data for Gallery is Collection. I am afraid to fail to update source, but second patch will reflect false information within Gallery. 
I tried several ways to incorporate it, but all failed.
Thanks in advance!

  • Dulat Profile Picture
    102 on at
    Re: Error for patch within for all.

    @WarrenBelz @LaurensM 

    Thanks a lot!!!

  • WarrenBelz Profile Picture
    148,684 Most Valuable Professional on at
    Re: Error for patch within for all.

    Hi @Dulat ,

    Both approaches are correct - I did not realise that @LaurensM had posted between when I opened the thread and responded.

     

  • LaurensM Profile Picture
    12,510 Super User 2025 Season 1 on at
    Re: Error for patch within for all.

    Hi @Dulat,

     

    I recommend @WarrenBelz' approach. I missed it when looking over the code, but you can remove the RenameColumn() function.

     

    When nesting record scope functions (e.g. ForAll, Filter, LookUp, AddColumns...) it is best practice to make one of the record scopes explicit by using As RecordScopeName (As Inner, As Main...). Otherwise Power Apps could get confused which ID column is actually being referred to. In the case of Warren's solution, your ForAll record is called _Col. (avoids having to rename it to IID) 

     

    I hope this helps!

  • Verified answer
    WarrenBelz Profile Picture
    148,684 Most Valuable Professional on at
    Re: Error for patch within for all.

    Hi @Dulat ,

    Maybe something like this

    ForAll(
     Filter(
     test_coll,
     IsChoosen
     ) As _Col,
     If(
     !Error(
     Patch(
     mesra_test,
     {ID: _Col.ID},
     {RevisionStatus:"For Deletion"}
     )
     ),
     Patch(
     test_coll,
     {ID: _Col.ID},
     {RevisionStatus:"For Deletion"}
     )
     )
    )

     

    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

  • Verified answer
    LaurensM Profile Picture
    12,510 Super User 2025 Season 1 on at
    Re: Error for patch within for all.

    Hi @Dulat,

     

    Please try the following adjustment:

    ForAll(
     RenameColumns(Filter(test_coll,IsChoosen),"ID","IID"),
     If(
     !IsBlankOrError(Patch(mesra_test,LookUp(mesra_test,ID=IID),{RevisionStatus:"For Deletion"})),
     Patch(test_coll,LookUp(test_coll,ID=IID),{RevisionStatus:"For Deletion"})
     )
    )

     

    If this solves your question, would you be so kind as to accept it as a solution & give it a thumbs up.

    Thanks!

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

Paul Stork – Community Spotlight

We are honored to recognize Paul Stork as our July 2025 Community…

Congratulations to the June Top 10 Community Leaders!

These are the community rock stars!

Announcing the Engage with the Community forum!

This forum is your space to connect, share, and grow!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 791 Most Valuable Professional

#2
MS.Ragavendar Profile Picture

MS.Ragavendar 410

#3
mmbr1606 Profile Picture

mmbr1606 275 Super User 2025 Season 1