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 / Error for patch within...
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!

Categories:
I have the same question (0)
  • Verified answer
    LaurensM Profile Picture
    12,516 Moderator on at

    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!

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

    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

  • LaurensM Profile Picture
    12,516 Moderator on at

    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!

  • WarrenBelz Profile Picture
    155,779 Most Valuable Professional on at

    Hi @Dulat ,

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

     

  • Dulat Profile Picture
    102 on at

    @WarrenBelz @LaurensM 

    Thanks a lot!!!

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 Launch!

Jump in, show your community spirit, and win prizes!

Kudos to our 2025 Community Spotlight Honorees

Expanding mentorship, skilling, and AI innovation

Congratulations to the May Top 10 Community Leaders!

These are the community rock stars!

Leaderboard > Power Apps

#1
Valantis Profile Picture

Valantis 477

#2
WarrenBelz Profile Picture

WarrenBelz 341 Most Valuable Professional

#3
11manish Profile Picture

11manish 317

Last 30 days Overall leaderboard