Embedded App: Message to Parent

Hello there :wave:

I tried to reproduce the code from this thread as well as from the documentation for posting messages from retool embeddings to the outer app and was not able to get any invocation of the message listeners.

Retool's onData won't be invoked nor the callback from window.addEventListener.

I tried posting the message both from inside a query and from a click handler but the only side effect of that is a console log from the iframe saying JSCode triggering postMessage.

I am using a draft release version and the updates are reflecting the embedding as expected (I added visual elements to differentiate between versions).

Also tried setting different targets such as http://parent.local, * and urlparams.href but none of them seem to differ.

What might I be missing?

Hi @Mathias_Parade,

Thanks for chiming in!

:thinking: I believe this should be working. I tested with * as the target and have it working in my own app.

Can you share a screenshot of the query that is resulting in the console log from the iframe saying JSCode triggering postMessage?

For example, triggering the below query from an event handler in my embedded app results in a parent app log: Received message from iframe... with the message "home"

When using releases, the iframe should only show the latest published version of your app, rather than the version that you see in the editor

I found out the postMessage was being invoked against the wrong parent (somehow). parent.parent.postMessage(...) worked just fine. The event origin is coming as "null" tho.

:thinking: Interesting - well, I'm glad you were able to move forward! Thanks for sharing for other folks