Does MktoForms2 have an onFailure? Is there a way for my codebase to log if a form submit fails

Highlighted
Level 1

Does MktoForms2 have an onFailure? Is there a way for my codebase to log if a form submit fails

For MktoForms2, there is an .onSuccess(callback)

but there doesn't seem to be a .onFailure(callback)

I've read through the api many times, I can't seem to figure out a way to find out if the form submit has failed.

Is there a way to do this? How do other people ensure they are aware when a form submission fails?

Thanks

6 REPLIES 6
Highlighted
Level 10 - Community Moderator

Re: Does MktoForms2 have an onFailure? Is there a way for my codebase to log if a form submit fails

Highlighted
Level 1

Re: Does MktoForms2 have an onFailure? Is there a way for my codebase to log if a form submit fails

Hi Sanford Whiteman‌, thanks so much for the blog post and the expertise.

I'm trying to implement it now. It occurred to me... is there any way to test my implementation? How would I be able to make it fail on purpose?

Question 2: "Remember, onSubmitError is for network and server errors, like a TCP/IP timeout/reset or a down server returning 404 or 500." - So, does it catch things like 'invalidInputMsg' or 'formSubmitFailedMsg'?

So far, I am unable to catch it when I intentionally try to fail by sending an incomplete form:

Screen Shot 2020-01-24 at 12.04.43 PM.png

When I get that error, my callback isn't getting called in FormsPlus.onSubmitError(myCallback). I can see that FormsPlus is correctly defined when I console.log(FormsPlus), so it's just not being called. 

So my question is, can those errors be caught using this method (in which case I implemented it wrong). Or can they not be caught?

In addition, are there any additional thoughts you have around how to best ensure the form submits go through properly?

TL;DR:

Question 1: How do I get my request to fail on purpose to test the implementation?

Question 2: is onSubmitError suppose to be able to catch invalidInputMsg

Thanks, I appreciate it. 

Highlighted
Level 10 - Community Moderator

Re: Does MktoForms2 have an onFailure? Is there a way for my codebase to log if a form submit fails

How are you generating invalid input - and how is this input invalid on the server side but would not be caught by onValidate on the client?

Highlighted
Level 1

Re: Does MktoForms2 have an onFailure? Is there a way for my codebase to log if a form submit fails

I see I see.

That's my mistake, we just do our own client side validation. In order to get that message 'invalidInputMsg' I removed the client side validation. But, it does get caught by the onValidate(callback). I will use that.

So that answers question 2, which was an oversight of onValidate() on my part.

I'm still curious if there is a way I could test if I have implemented onSubmitError correctly? Is there a way to get it to fail on purpose?

Thanks

Highlighted
Level 10 - Community Moderator

Re: Does MktoForms2 have an onFailure? Is there a way for my codebase to log if a form submit fails

I'm still curious if there is a way I could test if I have implemented onSubmitError correctly? Is there a way to get it to fail on purpose?

I run my requests through a proxy that I can set to drop packets.

You could change your HOSTS file (after loading the form!) so the destination URL of the form post is unreachable, i.e.

   0.0.0.0 app-sj01.marketo.com
Highlighted
Level 10 - Community Moderator

Re: Does MktoForms2 have an onFailure? Is there a way for my codebase to log if a form submit fails

Also, no need to @ - but if you do, please use the right profile! (The profile in the original response and all my posts here.)