Hey @jeanS, Welcome to Retool Community.
I understand your issue — this exact problem has been discussed before in the forum here: Force run JS code to rerun when variable changes.
The working solution shared there is as follows:
- Create a sample resource query (e.g. a “Query JSON with SQL”).
- Inside the query, simply reference your state variable like this:
SELECT
{{ monthlyDataState.value }}
- Set the query’s Run behavior to Automatic so that it reacts whenever the variable changes.
- In the Success event handler of this resource query, trigger your JS query.
That way, whenever monthlyDataState.value updates, the resource query automatically runs, and the success handler will in turn fire your JS query.
Here’s a screenshot for reference:
This approach is a reliable workaround since JS queries don’t natively re-run/automatic run behavior on global state changes. It ensures your logic always stays in sync with updates to the variable without needing manual triggers each time.
Hope this clears things up and gives you a smooth way forward ![]()
