APIs & Integrations

asa_curry
Member

Set sfdcCampaignId via onFormSubmit?

I’m trying to setup a dynamic page via hubdb that will require a form linked to a different SFDC campaign on each branch of the page. I think it should be simple enough to pass in the SFDC ID as set in the hubdb table via the onFormSubmit callback, but I am not clear on the syntax…

Can you run $.ajax inside the callback and post it via the API? or is there a simpler way?

Thank you!

0 Upvotes
3 Replies 3
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Set sfdcCampaignId via onFormSubmit?

Hi @Asa_Curry,

The article I linked above includes some frontend methods for pulling values from HubDB. They’re very similar in structure to the HTTP HubDB methods, the documentation for which I’ve included below. You could pull the relevant campaign ID from HubDB using these methods, and put it into the hidden form field using either the form’s onFormReady (if you can do it right when the form loads) or the 'onFormSubmit` (if you need to wait for submission) methods.

Get table rows

GET /hubdb/api/v1/tables/:tableId/rows - Get the rows for a specific HubDB table.


0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Set sfdcCampaignId via onFormSubmit?

Hi @Asa_Curry,

That might work, but the request probably won’t complete before the visitor is redirected after the form submission. While I’m not entirely sure what your setup is, you could use the HubDB HubL methods instead of the JSON HTTP methods:

HubDB

HubSpot's website platform supports data-driven content using a built-in native database called HubDB.

0 Upvotes
asa_curry
Member

Set sfdcCampaignId via onFormSubmit?

Hi Derek,

Could you elaborate on the HubDB methods you are referring to, or direct me to where you are looking in the documentation? I don’t see how to manipulate a form submit event or a lead record based using Hubl/HubDB in on the main HubDB link you provided.

Thank you!

0 Upvotes