APIs & Integrations

caseywise
Member

Noobie alert: Native form's onSubmit event handler or hook?

Hi guys, this is my first stab at any HS development. We’re integrating with SalesForce, but due to how we’ve frankensteined SalesForce we can’t sync, I promise I’ve researched the heck out of this, even selective sync can’t help, we’re making SalesForce do way too much and done too much data mangling.

Our implementer has created a native contact form for us which is great. First name, last name, email, city/state/zip, comments.

When the submit button is hit, in addition to submitting to HubSpot, we’d also like to hook our own code which will allow us to talk with our own API (which talks to our SalesForce).

Questions

  1. Is there an “onSubmit” or “postSubmit” event handler that I can hook my own code on to?
  2. Does is sound like I’m thinking about this the right way?
0 Upvotes
8 Replies 8
Not applicable

Noobie alert: Native form's onSubmit event handler or hook?

This page may help

0 Upvotes
terrance
Participant

Noobie alert: Native form's onSubmit event handler or hook?

@caseywise phema109 is right. Use that page, specifically onFormSubmit. If you need to handle the form submission elsewhere, you might be able to use jQuery to trigger the event you can read in from your own API integration. Something like $form.trigger('hubspot:form:submit') and then use jquery’s bind() to listen for that event and parse the data from the hubspot form in javascript. This is assuming you are using AJAX forms.

0 Upvotes
caseywise
Member

Noobie alert: Native form's onSubmit event handler or hook?

@pmanca, massively appreciate your input. I feel like I’m getting less dumber w/ HubSpot development, problem is more dumb still apparently needs shaken loose.

PROBLEM

Workflow isn’t triggering when I expect it to.

“Contact Us Submission” workflow

screenshot

OBJECTIVE

Without exception, every time our “Contact Us” form is submitted, our workflow is triggered, the contents of that form get POSTed to our WebHook.

BLOCKER

  • In my workflow history, I’m seeing: Contact was not enrolled because they already met the goal criteria and I expect to see Completed workflow
  • No history of the workflow triggering

WHAT I’VE TRIED TO FIX THIS

:warning:WARNING The following may expose you to hillbilly ghetto hackery :warning:

  • Set WorkFlow starting criteria to a condition I’m certain doesn’t exist with the examples I’m submitting to our Contact Us form screenshot
  • Set WorkFlow goal to conditions I’m certain don’t exist in example “Contact Us” form submissions,screenshot
0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Noobie alert: Native form's onSubmit event handler or hook?

@caseywise Have you tried checking the box to allow contacts to be re-enrolled when they have re-met the criteria?

at the bottom of the entrance criteria click change re-enrollement options
image

then check off to allow that.
image

0 Upvotes
caseywise
Member

Noobie alert: Native form's onSubmit event handler or hook?

Doing some reading on WebHooks/Workflows, this seems like it’ll work. Ironing out passing the data collected on our contact form to POST.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Noobie alert: Native form's onSubmit event handler or hook?

@caseywise I think you are going down the right path. Let me know if you have any troubles on the workflows.

0 Upvotes
3PETE
HubSpot Employee
HubSpot Employee

Noobie alert: Native form's onSubmit event handler or hook?

@caseywise is this a HubSpot form? Is the form embedded on your website or is the form on a page that is hosted by HubSpot?

0 Upvotes
caseywise
Member

Noobie alert: Native form's onSubmit event handler or hook?

Hi @pmanca, this is a native HubSpot form w/in our HS COS.

0 Upvotes