I need my module queries to run when inputs change

  • Goal: I need to trigger a query to run when data changes. This query is located in a module, and needs to run when the input from the app changes.

  • Steps: Read a bunch of stuff, searching if there were any hints. Clicked around to see if I saw any options that I could use.

  • Details: I have a lot of dashboards that basically use the same data to do different things. So, I have created 2 modules that query all the data, so that I can just include the module, rather than having to duplicate all the code that does the querying. BUT, the main query in the module needs to run when a particular input changes. How can I do this? It seems I can trigger a query in the app from the module, but not the other way around? It would be far better to use the data to trigger the query, rather than polling the data...

  • Screenshots:

Hi @nl-setech,

You should be able to achieve this with an event handler on the input. When you add one in the right-side menu, you'll get options like this:

image

If you want it to run the query whenever the input changes, select "Input value change", make the action "Control a Query" and then select the query you want to trigger.

We have the same Run behavior UI for all queries, but Automatic is always disabled for Javascript queries because they can trigger other queries and events.

You may need this relatively hacky workaround to solve your use case: Trigger a module query from the parent app

Ok. Yes. I was able to figure out something similar, based on @MikeCB ' s response. It's slightly different, however, since none of my applications have every used SQL, so I wasn't familiar with those type of queries.

My solution involved creating a hidden text display field that was set to the value of an input value on the module. I was able to add an event handler on change to that hidden field, and kick off my queries.

1 Like