Filter table based on parent window url

Hi there,
Complete Retool newbie here. I am wondering if it is possible to filter a postgres data source oby of the URL of the parent page?

eg. If I embed an app on my website at https://website.com/1234 can I have a table in that app filtered by column_value = 1234?

Hey @Henry!

You may be able to use a ParentWindow query (referenced here) for this. I don't know of a way to query the parent document object directly but if you store the page's URL in a DOM element you should be able to access it.

Say you have something like

<div id="page_url" hidden></div>

on your webpage and then set its value to be the page's URL in the same script where you embed Retool using something like

document.getElementById("page_url").innerHTML = document.URL;

You can then run the following query:

Which should return the URL you've stored in that element.

Could that work?

1 Like

Hi @Kabirdas,
I'm looking for something similar, is it not possible for the embedded app to see on which original domain it is without having that information in the iFrame itself?

Hello @whynot!

I am also to hear back from @Kabirdas on alternatives, but from my understanding the data which a retool app has access to is encapsulated in it's own codebase and to bring in new data such as URLs/app domains it needs to receive this data from a resource/query.

Hello @whynot,

You should be able to grab the URL params from your retool app and pass them into a query with dynamic JS interpolation using {{urlparams}} to grab the string and from there do some string manipulation to grab the data you need!