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

kimkijung
Level 1

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

hmm I think that still leaves me wondering why there isn't an onFail callback. Apart from form validations, this can range from rate limit errors to any unaccounted errors.

 

Is the solution to just add the same validations as the server-side email check and hope that it doesn't occur with any future changes? I think a lot cleaner way to do this is to add an error callback to form.submit(), but I am relatively new to Marketo and might be seeing this from the wrong angle.

 

In any case, thank you for your help! It was definitely informative and insightful.

SanfordWhiteman
Level 10 - Community Moderator

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

Is the solution to just add the same validations as the server-side email check and hope that it doesn't occur with any future changes?


Yes, that's the way all  HTML forms should be built, since there's no reason to waste a server roundtrip on non-malicious end users who happen to mistype something.

kimkijung
Level 1

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

I guess that makes sense for forms, but there are dozens of other use cases for a callback in case of a submit failure. Rate limits, server issues, weird validations on emails, etc. Is this something you've implemented before? Will the solution with FormsPlus module catch the 400 thrown from the mismatch in client and server validations for email as well as other common errors?

SanfordWhiteman
Level 10 - Community Moderator

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

Yep, handling domain-specific exceptions (not necessarily network or HTTP errors) is the right move in general.

 

If client and server validation rules are different, though, that's an error in the app itself, as it shouldn't be possible for an innocent user to generate an exception (unless everything requires a roundtrip which is really old-school!).

 

I'm not 100% sure these new types of validation errors are caught by my onFailure extension, but will definitely check for you.

kimkijung
Level 1

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

Hi Sanford,

 

I wanted to check in to see if you were able to test the validation error.

 

Thank you for your help!

SanfordWhiteman
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.)   

jesse
Level 1

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

Just for other googlers in the future, this can happen when using the API to submit the form if a field has HTML tags in it. It appears that validate() doesn't catch the issue, but the server does and returns a 400 code with errorType "invalid"