Can't refer to query in a global js function

  • Goal:

I am trying to build a global js function function getArticleRate(rateType, articleName) that I can call in the app. This function needs to use data from a query getArticlesRatesQuery that I defined ahead of time.

  • Steps:

I keep getting a message that "'getArticlesRatesQuery' is not defined." in my global js function, even though I can refer to the query in the rest of the app.

1 Like

I have the same issue and would be interested in guidance as to how to reference a query results set in the global Javascript section of the App.

Hi @Philippe_Mizrahi and @TravisM, to achieve this, we need another parameter for the JS function to pass in the query as an argument. Although functions from the App's preloaded JS can't access predefined queries, they can take them as an argument and trigger them within the function.

For example:

Here is a simple query we'll run:



Here is a variable we'll use as well:

And here is the preloaded JS:

Finally, we'll run the "repeatInput" function from a JS query on the App:

As we can see, it ran the query and it returned it's data. It was also able to reference a predefined variable.