cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
sfishe
Level: Powered On

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
Super User
Super User

Re: handling a SubmitForm failure

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

Re: handling a SubmitForm failure

@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

 

 

2 REPLIES 2
Super User
Super User

Re: handling a SubmitForm failure

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

Re: handling a SubmitForm failure

@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

 

 

Helpful resources

Announcements
firstImage

Watch Sessions On Demand!

Continue your learning in our online communities.

SecondImage

PowerApps Monthly Community Call

Next Wednesday, September 18th at 8am PDT

Power Platform 2019 release wave 2 plan

Power Platform 2019 release wave 2 plan

Features releasing from October 2019 through March 2020

FirstImage

Power Platform World Tour

Coming to a city near you

thirdimage

PowerApps Community User Group Member Badge

Fill out a quick form to claim your user group badge now!

FourthImage

Join PowerApps User Group!!

Connect, share, and learn with your peers year-round

SecondImage

Power Platform Summit North America

Register by September 5 to save $200

Top Kudoed Authors
Users Online
Currently online: 75 members 4,390 guests
Recent signins:
Please welcome our newest community members: