Calling a RestQuery with an input


I created a RestQuery that I want to call in a text field, with inputting one of its body key.
I tried things like these without success :
{{ translateQuery.text= "My Text"}}
{{ translateQuery.text("My Text")}}
{{translateQuery.body['0'].value="My Text"}}


I tried to use an intermediate variable, without success...
The intermediate variable is not updated and it is still my default value ("yes", translated in German "ja")

Hey there @Dymalle!

It looks like you have a repeating list of text components here, is that correct? If so, you might want to use this pattern to call your query for each item in the list.

If you want to set a value on an object in the Retool model, or trigger a query, you'll need to call the corresponding method. For setting the value on a temporary state that would be yourTempstate.setValue(), and for triggering a query that's yourQuery.trigger(). There's a great post on how to pass values to triggered queries here!

All of the above is best done in a JavaScript query. Transformers (either standalone or any expression in {{}}) are re-evaluated whenever one of their inputs is re-evaluated which makes any expression with side-effects really volatile, and many functions like query triggers don't work in them.

Let me know if any of those docs are helpful or raise additional questions!

1 Like

Thanks @Kabirdas,
I can't say yet if it solves it: I need to spend some time checking and testing this.
I'll keep you informed.

I tried with "await" and "trigger", but it seems that these are not accepted in the text field of a text component.
I think I'll go on with another strategy using a button triggering a script using a table... I am currently working on it. I think this would work better.

1 Like