I've got FormAssembly installed in my org and it's loading a form on an experience site (community). I'm trying to get my custom LWC on the site to listen to events coming from the form but nothing seems to work.
In my form script tags I'm firing a custom event:
<script>
window.onload = function() {
const message = 'testMessage';
let event = new CustomEvent("formMessage", { detail: message });
window.dispatchEvent(event);
console.log('formMessage event fired');
};
</script>
and on my LWC I add the event listener in the connected callback function:
connectedCallback() {
window.addEventListener("formMessage", (event) => {
console.log('formMessage event listener ' +event.detail)
});
}
Now I know the forms are embedded in an iFrame but I'm pretty sure I can listen to events coming from there. I've also made sure that the event is firing and that the listener is registered on my LWC before the form fires the event but I still get nothing on the other end.
Any idea what I'm missing?