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

Community site session details

Session Id : 1+B0Ha49m+gPsGz0ltCISh
Power Apps - Building Power Apps
Answered

Error for patch within for all.

Like (0) ShareShare
ReportReport
Posted on 12 Aug 2023 19:45:19 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!

I have the same question (0)
  • Dulat Profile Picture
    102 on 14 Aug 2023 at 02:50:08
    Re: Error for patch within for all.

    @WarrenBelz @LaurensM 

    Thanks a lot!!!

  • WarrenBelz Profile Picture
    149,646 Most Valuable Professional on 13 Aug 2023 at 00:58:42
    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 Moderator on 12 Aug 2023 at 20:53:36
    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
    149,646 Most Valuable Professional on 12 Aug 2023 at 20:28:14
    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 Moderator on 12 Aug 2023 at 20:11:55
    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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Telen Wang – Community Spotlight

We are honored to recognize Telen Wang as our August 2025 Community…

Congratulations to the July Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 688 Most Valuable Professional

#2
Michael E. Gernaey Profile Picture

Michael E. Gernaey 499 Super User 2025 Season 2

#3
MS.Ragavendar Profile Picture

MS.Ragavendar 410 Super User 2025 Season 2

Last 30 days Overall leaderboard
Loading complete