Queries with parameters

I have 5 buttons that trigger the same query, and I want to do different things based on which button was clicked

6 Likes

break me out

+1

You could make the button trigger a JavaScript query and then trigger the SQL queries (or different queries) w/different parameters like this: https://docs.retool.com/docs/scripting-retool

Specifically, you would use triggeredById inside a JS query. That will give you the name of the component that triggered the query.

@coleca's solution seems great, it'd just be nice if this was natively supported from the UI so there could be autosuggestions.

1 Like

+1
Would be really great, so you can make more generelt and reusable scripts

+1 on this

1 Like

I would suggest to create a temporary state.
For every button, you can make an action to set up the value of the temporary state.
Give the temporary state argument to the query.