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 / struggling with Patch ...
Power Apps
Answered

struggling with Patch and Error handling sequence

(0) ShareShare
ReportReport
Posted on by 1,257 Super User 2024 Season 1

I'm struggling with patch and error handling sequence !  I've no errors all is working but just not in the order I want ! 🙂

 

So I have multiple patch functions to different lists, they are sequentially done separated by ;

 

If first patch fails for what ever reason I want to catch the errors in the in a collection , show a message and don't continue the sequence and they can try again.  Sounds easy and that part is !  got that working fine.  However I want to do 3 things if the first patch fails and I can't do them concurrently (when I can put concurrent infront of the actions it works fine) The way I have it set up now if the first patch fails then it does all the things it's supposed to do but then it goes and sends the second patch !  I don't want that.. so I' know it's a matter of changing where brackets and syntax is but just don't know how to do it !  here's what I currently have 

Patch1 Actions ending with ;

If(!IsEmpty(Errors('mydatasource')),
Concurrent(Set(snothervariable,false),
UpdateContext({adialoguebox:true}),
Collect(myerrorcollection,AddColumns(Errors('mydatasource'),
column1,"text1",
column2,"text2",
TimeStamp,Now()

)))
;SaveData(myerrorcollection,"LocalErrors");
ForAll(myerrorcollection,Patch(
 'anerrorlogdatasource',
 Defaults('anerrorlogdatasource'),
 {column1:text1,
 column2:text2,
 ErrorMessage:Message,
 ErrorCode:Error,
 TimeStampOfError:TimeStamp
 })

),


2nd patch acion here...

So as I said above all works but it appears to send the 2nd patch action even if the first one doesn't work...  If remove the collection and save local data and any ;  just concurrently doing stuff it works as expected...

 

hopefully you can follow the above !

 

TIA

Categories:
I have the same question (0)
  • Verified answer
    WarrenBelz Profile Picture
    154,593 Most Valuable Professional on at

    Hi @vffdd ,

    A bit of bracketing - you need to close the Concurrent I think (but you do not really need it as you are not reading from or writing to a data source)

    If(
     !IsEmpty(Errors('mydatasource')),
     Concurrent(
     Set(
     snothervariable,
     false
     ),
     UpdateContext({adialoguebox:true})
     );
     Collect(
     myerrorcollection,
     AddColumns(
     Errors('mydatasource'),
     column1,
     "text1",
     column2,
     "text2",
     TimeStamp,
     Now()
     )
     );
     SaveData(
     myerrorcollection,
     "LocalErrors"
     );
     ForAll(
     myerrorcollection,
     Patch(
     'anerrorlogdatasource',
     Defaults('anerrorlogdatasource'),
     {
     column1:text1,
     column2:text2,
     ErrorMessage:Message,
     ErrorCode:Error,
     TimeStampOfError:TimeStamp
     }
     )
     ),
     Patch(
     2nd Patch . . . .

     

    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

  • vffdd Profile Picture
    1,257 Super User 2024 Season 1 on at

    Thanks @WarrenBelz 

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!

Leaderboard > Power Apps

#1
WarrenBelz Profile Picture

WarrenBelz 509 Most Valuable Professional

#2
Haque Profile Picture

Haque 302

#3
11manish Profile Picture

11manish 265

Last 30 days Overall leaderboard