How do I clear module inputs on form save/submitted?

I have a custom module with three inputs in a form which is in a dialog.
I have selected the 'Clear after submission' to clear the form and I have tried to call the form.clear() method 'newPlayerForm.clear() in my case' yet the form input values are not cleared.
Is there another way for me to clear these values?
Does it matter that I have both inputs and outputs for this module?

Hi @peteletkemanca :wave:

At the moment, triggering actions (queries) in modules from a parent app is pretty tricky to do. Can you tell me a little bit more about your setup so I can help look for workarounds? I'm wondering how disruptive it would be to move things in or out of your module.

Hi @Kabirdas thanks for your help with this.

This is just a learning project where I'm exploring the tools/environment.
What I want to do is to create a shared form element that I can use for both adding and editing database records.
I think it would be great if someone created a 'how to' or tutorial on how this could/should be done. I'm open to recommended practices on how to create and reuse custom components.

I'm using Retool (Docker) on premise with a MySQL/MariaDB database (Docker) in a Windows 10 Pro system primarily with Google Chrome.

You can use the event handler function on the query submitting the form to clear values in the modal when the query succeeds and also close the modal. You will want to select Control Component and then Clear value(do this for each field) and then add the last event handler to control component(the modal) and select close

You can also clear the form component as a whole BTW

The 'Set an output' does not allow me to provide any parameters as shown in the attached image.
I do not have any options to 'Clear' any values except for on form submission which I've enabled (as shown in my first posting) and that does not seem to do that much with my setup.

You can set up your module with a dummy query that watches for an input as mentioned in this thread.

  1. Create an input in the module and set the value to be the parent query or the parent input that you want to use to trigger the module query
  2. (a) Query JSON with SQL dummy query (b) select * from - this watches for changes to input1 and triggers this query on any changes (c) trigger target module query on success

Then 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!

In your case, the query that you're triggering with the dummy will be a JS query that actually clears the input fields and you'll want to add an event handler to the form in your parent app that prompts the input for the module to recalculate.

As I mentioned before it's a bit tricky to get working at the moment :sweat_smile: let me know if anything could use clarification!

1 Like

@Kabirdas What's the workaround nowadays? I don't see a Query JSON with SQL resource anymore. Has a solution for this use-case been formally implemented?

Hi @clarkmcc,

We haven't removed the Query JSON with SQL option. It should be available under

Code->Create new Resource query