Hi Amir, sorry about the slow reply.
Yes you found the right area with the Preloaded Javascript.
Mostly you will use this for function definitions, not actual script code.
That means you don't need to trigger() anything, simply call the function by its name in your code:
// Define the numbers to add
const num1 = 5;
const num2 = 3;
// Use the utility function with the provided numbers
const result = addNumbers(num1, num2);
console.log("Addition result:", result);
For example, put this in an event handler:
Also, I'm not totally sure but I think they might have deprecated the window.retool
namespace.
I can't access any objects in that which means .queries does not work.
I always just call query1.trigger()
.
Let me know if you got that or window.retool.data
to work so I can try it!
With your latest code I would probably (depending on how the rest of the app is structured) do these things:
Make containerFilterValues a state variable so you can access it anywhere via containerFilterValues.value
Keep trigggerBaseQueryWithFilter in the preloaded JS. I would use the syntax
function trigggerBaseQueryWithFilter(filterValue) ...
rather than a const and an anonymous function.
I wouldn't add an eventListener to the window unless absolutely necessary.
Generally you would make a JS query for containing the for (const filterValue ...
and set it to run on page load.
I find Retool to be pretty confusing about where it would like me to put code, so that the app doesn't become a complete mess. If anyone like @pyrrho can help with best practices that would be great.
Good luck!