mktoForms2 - How to handle reCAPTCHA v3 AND another async function response (SendSafely) during .onValidate() | Community
Skip to main content
New Participant
June 10, 2022
Solved

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

  • June 10, 2022
  • 1 reply
  • 2157 views

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?

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by SanfordWhiteman

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

1 reply

SanfordWhiteman
SanfordWhitemanAccepted solution
New Participant
June 11, 2022

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

New Participant
June 12, 2022

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