Sequence JS to be triggered

Hi Retool Team,

How can I set the sequence of JS queries to be triggered?

For example:

  • I trigger query 1
  • On success of query1, I want to trigger query2
  • On success of query2, I want to trigger query3, and so on

Now in Retool, the “On success trigger” will trigger query 2 and 3 at the same time (asynchronous).

How do I set a delay that query3 will only be triggered when query2 finishes running?

Thanks.

Hey @oliver.ng! We have a section in our documentation that focuses on this. Each query has an onSuccess method you can use.

query1.trigger({
  onSuccess: {
    query2.trigger({
      onSuccess: {
        query3.trigger()
      }
    })
  }
})

Hi Justin,

Thanks for the reply. I followed your syntax but it seems not permitted by Retool

Screenshot 2021-03-22 at 13.05.15

@oliver.ng do you have the query name correctly entered? Looks like Retool doesn’t think that reset_fx_state is a query?

just to check. reset_fx_state is a js query, can js query be wrapped within the onSuccess object?

@oliver.ng figured it out: you need to add the function() syntax to your onSuccess hook, like so:

mySQL_add_leg.trigger({
  onSuccess: function() {
    reset_fx_state.trigger()
  }
})

LMK if this works!

1 Like