We’ve had a client that needed to set up the Gravity Forms on their website to set the recorded contacts in a different business unit to their main profile.
That shouldn’t be too hard should it?
Well it turns out that it isn’t exactly easy. Normally I’d expect that there’s settings for this, but because Hubspot’s Business Units system is currently in beta, there’s nothing built into the available Gravity Forms add-in that can take care of this.
The problem is that the Business Unit setting in Hupspot forms can only be set when a form is created. It can’t be edited at all after that, and when you use the Hubspot add-on for Gravity Forms, the add-on creates that Hubspot form automatically when you set up a feed so there’s no system in place to let you set a value for the Business Unit when the form is created.
I asked Hubspot and they couldn’t tell me what was needed as the Gravity Forms add in was written by Gravity Forms. So I contacted Gravity Forms and asked the same question… can I set the Business Unit for a form? They replied to me very quickly (well, overnight but I’m in Australia, so it was same-day for them) with a code snippet that they said should work.
// HubSpot Business Unit ID .add_filter( 'gform_hubspot_form_object_pre_save_feed', 'gf_hubspot_bussiness_unit', 10, 3 ); function gf_hubspot_bussiness_unit( $hs_form, $feed_meta, $form ){ gf_hspot()->log_debug( 'Running for Form ID: ' . form['id'] ); // Only for one form. if ( form['id'] != 2 ) { // Change 2 to your form id number. return $hs_form; } $hs_form['businessUnitId'] = 9999; // Replace 9999 with your Bussiness Unit ID. gf_hspot()->log_debug( 'HS Form Object: ' . $hs_form ); return $hs_form; }
The good news is that it works! Using this code and setting the proper Business Unit ID, the forms were created in Hubspot correctly and everyone was happy. This deserves a big shout-out to Gravity Forms for their help with what turned out to be a prety easy solution.