I want to get the current conversation data from Missive which has Retool embedded, and then store the data in a variable. This needs to update when the conversation changes.
The state is not getting updated when the conversation changes. I am not able to set the variable from the parent window in order to use it in following queries and APIs.
Steps I've taken to troubleshoot:
I have a ParentWindow which returns the conversation data. I am able to see (through a JSON explorer) the data update when I click on different conversations. I've added success event triggers here to set the var but learned that this only happens on page load.
I've created another query to run on page load that adds an event listener and listens for the PARENT_WINDOW_RESULT (which is the postMessage I can see in the console of Missive). The listener will set the state with the value I need.
That also does not work, so I created a empty SQL query on load to trigger the query as well. No luck there.
How can I set up the event listener correctly to get the data from the parent window and set it in a variable (clientId) that gets updated in the components/APIs using the value?
Can you elaborate a bit more on how you've built this custom integration? Are you directly embedding the Retool app or have you built an encapsulating application to act as a sort of proxy? More specifically, what URL did you specify when creating the integration?
I don't need to communicate back to the parent window (Missive), but instead I just want to listen to changes in the parent window and make sure that data can be passed between queries here in Retool.
Got it - I had no idea there was an existing integration. Thanks!
The primary issue here is that Parent Window queries don't behave like normal queries, both in the way they are triggered and in the way they handle callbacks. This isn't well documented, at best, and actually feels a bit buggy. I'll talk to the team and take a closer look!
Fortunately, there's an effective - though admittedly quirky - workaround:
This works because getConvo.data automatically updates when selecting a new conversation in Missive, which in turn causes triggerOnConvoChange to run. This particular query doesn't actually do anything except listen for changes and, upon completion, update the value of convoData.
I hope this helps! Let me know if you have any questions and I'll follow up here with any of my own updates.