Set additionalScope data to triggerQuery when called from a component

I'm working with a custom component that needs to trigger a query with some additionalScope data.

I'm getting the query to trigger with window.Retool.triggerQuery('save_new_print') but am unable to figure out how to pass data along that query call.

What am I missing?

Any chance you can share what you are trying to pass into the query?

Here's what I have done with an onClick event on a button for adding Terms into a table:
This is the additionalScope trigger fired when clicking on the button
for(i=0;i<terms.value.length; i++){

additionalScope: {
term1: somefield.value,

onSuccess: function(data) {
console.log('Successully ran!');
onFailure: function(error){
console.log("Something broke");


//Here is the query
INSERT INTO terms(term1, term2) VALUES ({{term1}}, {{term2}})

Note the curly brackets at the end of the query are the values from the additionalScope

Hey @ScottR,

This would work if it was in a JS query but not in a custom component. With a component I need to call (afaik) triggerQuery which is available in the window.Retool object.

This works for example: window.Retool.triggerQuery('save_new_print') but unable to pass any additionalScope to that call. I'm probably missing the formatting here (how the data gets passed to the function)

Sorry about that - my bad. I haven't worked with a react component yet but in reading this page just now, it might help you?

No worries :slight_smile: read through all the docs but couldn't find anything :cry:

Hey minijohn, I'm happy to offer a suggestion here :grinning_face_with_smiling_eyes: In our docs on how to trigger queries from your custom component it suggests that you pass the data you want to be used in your query to your app separately using modelUpdate() and then reference that value in the query that is triggered. Could that work for your use case?

Hey @everett_smith,

Aware of this but doesn't work for my use-case unfortunately :cry: So is it right to assume that triggerQuery doesn't accept any parameters then?

If so, I'll change the implementation to work with modelUpdate

Hey minijohn, Unfortunately, no, triggerQuery doesn't accept parameters. Hopefully, you can make this work by passing your parameters with model and modelUpdate!

1 Like