Components not refreshing in user mode and preview mode but working fine in edit mode

  • Goal: I have a couple of user inputs being taken, then these inputs are sent to the DB via SQL. This data is to be displayed using a list view. All of this is working perfectly fine when I try it out during the edit mode. But when I go to user mode or the preview mode, the list view is not clearing its instance values.

  • What have you tried so far? I tried using the clear instance values and reset instance values event handlers both via code and via the event handler config panel. I have included the event handler to run the JS query so so that the data is updated every time.

  • Here, the plus icon is the one with the event handler. Screenshots have been attached for better understanding.

Again, all of it works just as expected when editing, but not in the user mode and preview mode

image

1 Like

Hey @vinayaka.smallbay
Welcome to the Retool Community!

I understand the issue you're facing. Instead of running a single script, consider calling three different events. In these events:

  1. Control Query Action Type: Trigger your first query.
  2. Control Query Action Type: Trigger your second query.
  3. Control Component Action Type: Clear the instance value.

By setting up these actions separately, you can better manage and control the flow of your application. If you need further assistance or have additional questions, feel free to ask. We're here to help!

image

@ZeroCodez
I tried this. But all three run concurrently, causing the components to refresh while the query runs. My query is one which takes the component's input and puts it into the database. I need the input fields to clear only after the query run is complete. Hence the code route.

1 Like

Hi @vinayaka.smallbay, welcome to the forum! :wave:

There are a couple of ways we can do this. The fastest way is to just add await at the beginning of each line on your event handler:

Screenshot 2024-08-16 at 12.30.42 PM

This will ensure each call is fulfilled (or rejected) before the next one runs.

Let us know how it goes!

1 Like