Trigger JS Query via button does not display console logs? Is this a bug?

I have a basic button on my Retool dashboard.

There's an on-click event handler which triggers a JS query.

This is a very simple script in which I want to perform some actions (such as trigger a MongoDB query and feed back the information to a table etc.). I'm just using the button to test my query before I allow it to run on page load.

When I click the button however, I don't see my console.log anywhere.

Is this a bug?

Using the 'Run code' event handler, this works fine. But does not when I trigger the JS query. Why is that? I don't want to test my code in a 'Run code' event handler, I'd like to use my JS query instead - because that's what I will be using for other things on the page.


I have realised that this JS query needs a return value in order to actually trigger.
If I add return null at the end of the script, I can see my console.log...

Hey @krynv!

That seems odd :thinking: you should still see console logs without needing to return a value:

In the first screenshot you posted it looked as though the query hadn't been saved yet (note the "Save" button is still blue). Can you try double-checking to see if that might have caused the issue? It can be easy to overlook when testing, which I still do on occasion :sweat_smile:.

Thanks for your reply!
It seems this is working now.

Unable to recall if I had saved the query when I composed the OP - I thought I had done, but perhaps I did not.
Nonetheless, I do not have any issues now.

No problem! Good to hear it's working :slightly_smiling_face: