Manually Updating a Form


I have a landing page that is called from a third party, and they pass in some query parameters. I want to pre-populate some of my form variables using the values for these parameters.

Because the form does not exist when onDomContentReady fires, I am forced to poll for the presence of the form fields. Once the fields are present, I update the form field values. Unfortunately, immediately after I do this, HubSpot deletes the values I set because their is nothing in the database mapped to that field.

I can think of a couple better ways to do this, but I don’t know if the API supports it.

  1. Firstly, does the form api have an event it fires that I can attach a listener as to when the form has rendered? This would at least allow me to skip the hacky polling process.
  2. Secondly, is it possible to configure the code that loads the form to provide form values to use in lieu of what HubSpot thinks is in the database?

For those that suggest I wait 100 ms after the form fields are present to write my values in place in order to defeat the React code that clears the field… On any validation event, the form fields are again wiped out by HubSpot. That wouldn’t be good behavior under any conditions, so I’m not sure what is going on there.

Thanks for any assistance.


@GCP, There is no fixed interval that forms will be loaded, what if the page or internet connection is slow.
what you can try to see,if the form is loaded by checking regularly form element has loaded on page as soon as you find it you might do what ever you like.
We needed a workaround with twitter api, after tweets loaded I needed to pass that information to twitter.
We checked once twitter posts were available , then only we called our function and latter cleared function that was on set-interval.

Let me know if that was helpful…