cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
sfishe
Helper II
Helper II

handling a SubmitForm failure

On a Save form button I have the following OnSelect:

SubmitForm(EphysExpEdit); If (patchLookupEphys = true, Patch('Exp Slice Ephys 2', Last('Exp Slice Ephys 2'), {Animal_rel:{'@odata.type':"#Microsoft.Azure.Connectors.SharePoint.SPListExpandedReference", Id:Gallery_Animals.Selected.ID, Value:Gallery_Animals.Selected.Title }} )); UpdateContext({patchLookupEphys: false})

A couple of times recently I've had an issue where the SubmitForm function fails for some unknown reason, and then the rest of the arguments are executed. Of course this causes a problem because the following arguments rely on the SubmitForm function working as they modify the Last() record. (I have to do this annoyingly hacky Patch() stuff because PowerApps doesnt handle linked SharePoint lists well).

 

What would be the best way of handling potential errors from SubmitForm, so the rest of the arguments only are executed if the submission works?

 

Thanks

2 ACCEPTED SOLUTIONS

Accepted Solutions
Drrickryp
Super User
Super User

Put the commands in the "on success" dropdown of the form to be submitted..

View solution in original post

@Drrickryp, goodone forms are great for some basic built in errorchecking process. Can I add some more information please?

@sfishe, Click on the form to get all the form controls in the properties panel on the right.

Play around with your strategy by shifting your code from the button to the 

OnSuccess (Do this if the form submission succeeds)

OnFailure (Do this if the form submission fails)

OnReset (Do that upon form reset function())

 

If you string it all together on the button, you will get an error because alot of the code is only appropriate after a submission of the form. Especially patch functions with rules like Last().

 

onsucceess.PNG

 

 

View solution in original post

3 REPLIES 3
Drrickryp
Super User
Super User

Put the commands in the "on success" dropdown of the form to be submitted..

@Drrickryp, goodone forms are great for some basic built in errorchecking process. Can I add some more information please?

@sfishe, Click on the form to get all the form controls in the properties panel on the right.

Play around with your strategy by shifting your code from the button to the 

OnSuccess (Do this if the form submission succeeds)

OnFailure (Do this if the form submission fails)

OnReset (Do that upon form reset function())

 

If you string it all together on the button, you will get an error because alot of the code is only appropriate after a submission of the form. Especially patch functions with rules like Last().

 

onsucceess.PNG

 

 

Thank you, I was wondering how to perform an action only on success

Helpful resources

Announcements
Super User 2 - 2022 Congratulations 768x460.png

Welcome Super Users

The Super User program for 2022 - Season 2 has kicked off!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

<
Users online (4,939)