Global form event not returning expected values for data

We want to send the inputs of a form to a third party, but the global form event for hsFormCallback is not returning any data.
Expected behaviour is that data contains the form fields and values for the onFormSubmit event, as per https://developers.hubspot.com/global-form-events.
Looked to see if it was in other form events, but it’s not.

Console code:

window.addEventListener('message', event => {
 if(event.data.type === 'hsFormCallback') {
 console.log(event.data)
 }
});

What gets logged for onFormSubmit (notice that data is an empty object, not an array):

{type: "hsFormCallback",eventName: "onFormSubmit",id: "9c40de30-ed79-4565-a897-637c36563bfd",data: {…}}data: {}eventName: "onFormSubmit"id: "9c40de30-ed79-4565-a897-637c36563bfd"type: "hsFormCallback"__proto__: Object}

Documentation says this event will return something like:

 // Global event
 {
 type: 'hsFormCallback',
 eventName: 'onFormSubmit',
 id: 'Id of form submitted',
 data: [ // Array containing the names and values of the fields submitted
 {
 name: 'email',
 value: 'test@example.com'
 },
 {
 name: 'firstName',
 value: 'Jane'
 },
 {
 name: 'lastName',
 value: 'Doe'
 }
 ]
 }  

Is there something I’m doing wrong here?

Hey @cwar082 ,

I’m not able to reproduce this behavior on my end: When I log the event data of a form submission, I’m seeing the `data` array appear correctly. Check out this example page: HTML Form Test Page

Can you give me an example page and/or form where you’re seeing this behavior?

Hello!
I can confirm that I am experiencing the same issue where onFormSubmit returns an empty Object in `data`.

Form ID: 26de56f1-283f-4e69-93ad-102c067eb119

I have several forms with this issue, and other similar forms which work as expected, and so have not been able to identify the reason.

Hi @Derek_Gervais

Here’s the test form: https://c.leadto.sale/hubspot/.

I’ve tried your form and I am getting the data array successfully on it - not sure why ours isn’t working.

Thanks,

Curtis

Hey @cwar082 ,

This appears extremely similar to an existing issue that was recently resolved, but it looks like I’m still able to reproduce this on your sample page. Let me dig into this further with my team to see what might be going on. I’ll update this topic when I have more information.

Hey @cwar082 ,

I was actually able to get to the bottom of this right away. The onFormSubmit event & callback both depend on jQuery to function properly. Since your example page doesn’t include jQuery, the form values aren’t properly pulled into the event. I’d advise including jQuery on your page(s) to fix this.