How can I pass the magic "i" value from action button to query?

I have action buttons in the last column of the table and when I click on it executes the JS code below:

image

I want to somehow pass the magic "I" to the queries and use them like this:

...
	JOIN customers ON customers.id = accounts.customer_id
WHERE
	orders.id = {{ table1.data[i].id }};

I need to access the "id" field from the table where the action button belongs.

How can I pass the value to the query?

Hi @ckissi!

You’d want to use the additionalScope option in the trigger method to pass in the i or the table1.data[i].id value. That would look like this:

line_items.trigger( {
additionalScope: {i:i} 
} );

There’s some more info and examples on that here: https://docs.retool.com/docs/scripting-retool#querytriggeroptions

1 Like