Try to use window.parent.postMessage(“msg”, “*”) and do a test.
Did you import the hubspot scripts?
Test the function outside the form create function.
console.log the event onMessage.
You should see the window object on Dev Tools log (Chrome F12).
Thank you, I tried window.parent.postMessage(“msg”, “*”). I was testing in the preview which has a different url than the production website and that was blocking the messaging. I still get the javascript error but the Messaging works so I imagine it is unrelated to my script.