Run Query on Page Load - Dynamic FX

Hi team,

It would be great if the "Run this query on page load" setting option could be made dynamic with an FX button.

A use case scenario I currently have: if a global variable has data, then the page query shouldn't run on page load, where as it should if the variable is empty or the desired data is not available.

Thanks!

Hi @MiguelOrtiz,

I'm sure you already have a workaround. Here's what I have done:

  1. Turn off “Run this query on page load” for your main query (getClients for example).

  2. Add a JavaScript query (call it maybeRunQuery) and set it to run on page load:

if (!globalVariable.value || globalVariable.value.length === 0) {
  getClients.trigger();
}
1 Like

Thanks @Shawn_Optipath.

For some reason I had recorded in my mind that JS queries didn't have the option to "run this query on page load". Definitely a better workaround that the one I had.

Thanks!

1 Like

That is a decent workaround - thanks for sharing, @Shawn_Optipath. :+1: I've still documented this request internally and will provide an update here as soon as possible!

2 Likes