Skip to main content

Notifications

Power Apps - Building Power Apps
Answered

struggling with Patch and Error handling sequence

(0) ShareShare
ReportReport
Posted on by 1,257

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:
  • vffdd Profile Picture
    vffdd 1,257 on at
    Re: struggling with Patch and Error handling sequence

    Thanks @WarrenBelz 

  • Verified answer
    WarrenBelz Profile Picture
    WarrenBelz 145,666 on at
    Re: struggling with Patch and Error handling sequence

    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

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

Microsoft Kickstarter Events…

Register for Microsoft Kickstarter Events…

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Leaderboard

#1
WarrenBelz Profile Picture

WarrenBelz 145,666

#2
RandyHayes Profile Picture

RandyHayes 76,287

#3
Pstork1 Profile Picture

Pstork1 64,996

Leaderboard