Conditional Query Best Pattern Question

Depending on the result set of query1 I want to trigger either query2 or query3. Is there a recommended pattern for this? It looks like I can user trigger for this but also wondering if there is a better way?

1 Like

Hey @vancea47 - I’m definitely interested in what the community has to say about this. My guess would be to use a router (via a JS Code query) that runs query_x.trigger() based on some condition.

In general, using the .trigger() method in a Run JS Code query will be the most flexible. For simpler returns, you could use this approach:

If query2 and query3 are set to run “When inputs change”, you could also set their disable query settings (under the advanced tab in the query editor) to disable the query if the condition isn’t met.

I.E. if query1 returns as either “user” or “admin”, you could set each query to be disabled if {{ != "user"}} and {{ != "admin"}}

1 Like