Disabling auto refresh on queries

I have a query that I want to auto refresh if any of the data has a certain field in a certain state. This is easily achieved with this bit of code in the Disable Query field in advanced:

{{deploymentsGet.data.filter(e => e.status == 'DEPLOYING').length > 0 ? false : true }}

The issue is, then the refresh button on the table doesn't work. Is there a way to disable auto refresh but not disable the query?

If the query is loading the data in the table, no.
Any more information you can share?

The query is loading the data in the table, the table has a refresh button. I want the table to auto refresh if it has any rows with status==DEPLOYING. I want the refresh button to still be able to do deploymentsGet.trigger() when there are no rows with status==DEPLOYING

Bottom line, disable auto refresh I would see as distinct from disable query

Hello, I get your means until I make the testing app.
You want to still trigger the query via click fresh button to get the data(a.k: manually) when the query is disable.
unfortunely, when the query disable, it won't response to trigger until you enable it.

Here is my workaround for your use case - use variable.

first, define a variable named autoRefresh.
and set it default value to {{deploymentsGet.data.filter(e => e.status == 'DEPLOYING').length > 0 ? false : true }}.

Then bind it to deploymentsGet 's in the Disable Query field in advanced

and set the disabled option of fresh button to {{deploymentsGet.data.filter(e => e.status == 'DEPLOYING').length > 0 ? true: false }} be notice that the true and false is change the position. That's said when autoRefresh mode is on, you can't click the refresh button.

then add the event handler to the refresh button
let lastValueOf_autoRefresh = autoRefresh.value; autoRefresh.setValue(false); deploymentsGet.trigger({onSuccess: function (data) { autoRefresh.setValue(lastValueOf_autoRefresh) }, });


In this js block, every time you trigger the query, you need to enable it by setting autoRefresh.value to false firstly. Then after the trigger success, you need to restore it value to the last state[false or true].

Here is json of my test app, you can upload to create app to check it.
test.json (15.2 KB)

Thanks Anson! That was a lot of detail you provided, much appreciated.

To the Retool team, that is a big workaround for something very simple. Could I please request a new feature.

In advanced tab of queries, have 2 settings, disableQuery and disableAutoRefresh, they are separate things.

Best regards

Rich

Hey @rjones-cto! What exact behavior are you referring to with 'auto-refresh'? Specifically, what is triggering the auto-refresh on this table?