CMS Development

Siyabonga
Membre

Embedded form function

Résolue

Is there a way to ensure that my method inside onFormSubmit has fully run before the forms redirect happens?

0 Votes
1 Solution acceptée
lscanlan
Solution
Ancien salarié HubSpot
Ancien salarié HubSpot

Embedded form function

Résolue

Hi @Siyabonga,

 

So far as I know, that's not possible. I believe the form redirect creates a new thread in the browser, which the callback functions don't have access to. There is some time before the redirect happens, so if you're running code that only takes a few milliseconds, the code should run I'd think. But if you're trying to do something that takes more time, like with timeouts or with promises, you could consider adding the redirect into your callback function. And then within the form editor, just select the inline thank you message option instead of the redirect.

 

You've probably seen our docs, but we have those callbacks and events documented here: https://developers.hubspot.com/docs/methods/forms/advanced_form_options and here: https://developers.hubspot.com/global-form-events.

 

If you're having trouble with a specific page, feel free to let me know and link it here.

 

Thanks,

Leland

Leland Scanlan

HubSpot Developer Support

Voir la solution dans l'envoi d'origine

0 Votes
1 Réponse
lscanlan
Solution
Ancien salarié HubSpot
Ancien salarié HubSpot

Embedded form function

Résolue

Hi @Siyabonga,

 

So far as I know, that's not possible. I believe the form redirect creates a new thread in the browser, which the callback functions don't have access to. There is some time before the redirect happens, so if you're running code that only takes a few milliseconds, the code should run I'd think. But if you're trying to do something that takes more time, like with timeouts or with promises, you could consider adding the redirect into your callback function. And then within the form editor, just select the inline thank you message option instead of the redirect.

 

You've probably seen our docs, but we have those callbacks and events documented here: https://developers.hubspot.com/docs/methods/forms/advanced_form_options and here: https://developers.hubspot.com/global-form-events.

 

If you're having trouble with a specific page, feel free to let me know and link it here.

 

Thanks,

Leland

Leland Scanlan

HubSpot Developer Support
0 Votes