I have a select object on the global header. If the select changes, I want to call the resetFilter-function of a table on a page. You can't set event handler from global objects to change local objects. Could anybody help?
Hey @bauergeorg,
A similar question was made some months ago here:
And I haven't seen any updates related to this, unfortunately.
Thank you @MiguelOrtiz for your message. Bad to here there is no way to do this. The issue, you recommend, seems to be closed.
I think there is no feature on the retool plan, right? @Tess
The only solution for my problem is to set a global value if the select-component changes. On the page I write an jsquery which polls the global value. If this value has been changed, i change my page (local) component/object. This seems not to the best way (related to the perfomance).
Regards, Georg
Hey @bauergeorg - thanks for reaching out.
To @MiguelOrtiz's point, there isn't a formal solution to this particular problem. There is, however, a functional workaround that doesn't require polling and thus doesn't have a significant impact on performance.
The basic idea is to write a dummy query on the page that references the globally scoped object. I typically choose a Query JSON with SQL
one because it executes client-side and can still have its Run behavior
set to Automatic
. In the below example, this setup means any changes to globalVariable
will trigger dummyQuery
.
At that point, all we have to do is trigger actualQuery
on the success of dummyQuery
.
It's a bit convoluted but works well! Let me know if you have any questions.
@Darren is there a possibility to trigger the query only on change of the variable and not on the page load?
+1 to Darren's suggestion. I had a light bulb moment yesterday of pretty much the same solution and solved my week long problem.
In my solution my global variable was a dummy variable.
Default value of 0 that was then changed by global processes to trigger the page process.
It did so by flipping the state from 1 to 0 and vice versa
(if globalDummyVariable = 1 then set to 0 otherwise set to 1)
Now for your case, and this might not be the most elegant solution, you could:
- set the initital value of the global dummy variable to A
- configure your code not to run if the variable equals A
- Have your global code flip the variable from A to 1, and flip flop 1 and 0 going forward
(IF variable = A THEN 1 ELSEIF variable =1 THEN 0 ELSE 1)
You can implement something similar to what @ferret141 described above. Essentially, you'll want to disable query_dummy
whenever the value of global_var_appMode
hasn't yet been set. Or, more generally, is equal to its initial value.