SOLVED

Re: mktoForms2 - How to handle reCAPTCHA v3 AND another async function response (SendSafely) during .onValidate()

Go to solution
Todd_Berlin
Level 2

mktoForms2 - How to handle reCAPTCHA v3 AND another async function response (SendSafely) during .onValidate()

I've successfully followed the @SanfordWhiteman method for reCAPTCHA v3 - very thankful for that. Thank you!

 

We also use SendSafely for document upload, following their guidelines here. The widget.finalizePackage method (API reference) is asynchronous. When trying to use both SendSafely and reCAPTCHA on a form (with the standard code from the links above), we've had trouble with either duplicate leads coming into Marketo, or duplicate form fills for the same lead.

 

I've tried refactoring the two blocks into one in multiple different ways to resolve the duplicates. The best success I've had is to stop the duplicate, but the reCAPTCHA 'Fingerprint' hasn't made it onto the form (even though it's logging in the console). I'm sure it's something to do with the two async functions resolving at different times, but I only know enough code to be a slightly helpful - not a developer.

 

Has anyone done something similar before that you could share advice, pseudo-code for how I should aiming to solve, or actual code that might help?

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: mktoForms2 - How to handle reCAPTCHA v3 AND another async function response (SendSafely) during .onValidate()

You must make sure each listener cooperates with previous and subsequent ones, i.e. don’t just set the form as submitable when the current listener thinks it’s submitable. As shown here:

MktoForms2 :: onValidate Chain

View solution in original post

2 REPLIES 2
SanfordWhiteman
Level 10 - Community Moderator

Re: mktoForms2 - How to handle reCAPTCHA v3 AND another async function response (SendSafely) during .onValidate()

You must make sure each listener cooperates with previous and subsequent ones, i.e. don’t just set the form as submitable when the current listener thinks it’s submitable. As shown here:

MktoForms2 :: onValidate Chain

Todd_Berlin
Level 2

Re: mktoForms2 - How to handle reCAPTCHA v3 AND another async function response (SendSafely) during .onValidate()

Makes a lot of sense, thanks for that. I think I was looking at it for too long without a break...