Currently, the best/only way to trigger a query inside a module FROM the parent app would be to use this workaround:
Create a module input (this is a setting on the left side of the page when building your module) and set the value to be the parent query or the parent input that you want to use to trigger the module query. In this example, I want to trigger my module query whenever my parent app query, titled parentQuery, runs.
(a) Create a "Query JSON with SQL" dummy query that runs (b) select * from {{input1.value}}. This watches for changes to input1 and triggers this query on any changes. Then, (c) add a Success event handler to this dummy query that triggers your target module query.
Now, in your parent app, just make a change to whatever you set input1 to (in the module) and you should see the module query get triggered!
I've also attached an export of the module used in this example so you can look around if that's helpful at all You can import this JSON file by clicking Create new (on your Retool organization's home page) > From JSON.
I really need a way to clear one input field in our module.
My intuition would be to add a "Method" to the component, but that doesn't exists, so I try "Inputs" instead.
I press "Add Input", name it "clear", and set the type to "Query".
Then I add a "Success" handler that clears my input on the "Module Input Query", as that seems to be the only way.
Finally I add the module to an app and try to trigger the input. No matter what I try, "clear" is just a string, and the module only has a weird unusable "Set an output" method.
So that approach did not work. Then I tried to add a "Javascript query" to the module instead that does the same thing.
And the same thing happens. The "Javascript query" named "clear" is still just a string, no matter how I try to use it in an app.
I'd really love a way to add methods to modules - am I missing something? I feel like this is a common use case for modules
Hey @oles! I haven't been able to reproduce this just yet. Would you mind sharing some screenshots of your setup? And I assume the workaround above doesn't work for your use case?
I'm still not sure how it actually works, but passing in a "Temporary state" and using it as the "Default value" on an input in the module - causes it to reset on submit!
I'd still love for a better or clearer way to do it, like a "Method" or "Event" input type on modules, as this feels like a workaround, and not intuitive (for me, at least)
It's sort of working, but I'm unable to make it not trigger on page load, causing chaos in my modules.
I've tried a bunch of workarounds with temporary state, the "Disable query"-feature in queries, but nothing really solved it, and in the end, it's a mess and hard to maintain and understand
Another +1 from me on this feature - it's really important when you're using modules for shared functionality across apps - something our team is using more and more - especially now that we're using Retool for all our internal apps