Write data to the selected row

Hi, I'm new to Retool but can't seem to find an answer on here for something I'm sure is very simple.

I have a table from Google Sheets and am looking to take the contents of a cell of a single selected row, pass that to another query and then return the result back to another cell a different column of the same (selected) row. I have got the first two parts working fine but I can't seem to be able to write back to the selected row.

I have this working but this just writes the contents of 'code' to the column 'coupon' in the next empty row:

[ {"coupon": {{ addPromo.data.code }} } ]

I'm trying things like:

[ {"coupon": {{ addPromo.selectedRow.data.code }} } ]

But I can't seem to get the syntax right for writing the data back to the correct row in the Google Sheet

Is there something obvious I'm doing wrong?

Thanks,
Chris

I should say, I'm using a Transformer to get the data from the selected row for my first step like this:

I'm using a Transformer because it works rather than it being the correct way to go about it!!

Hi @Chris_Hardcastle, welcome to the community! :wave:

For that spreadsheet, do you have a primary key that's unique for each row? I think you want to use the Action Type Update a spreadsheet, assuming you're only wanting to update a single row each time.

Specify your Sheet Name, your unique column, and use the one you have in the screenshot to Update value field. For your unique column/filter by value, you need to use something from your {{ table1.selectedRow.data.your_unique_column }}.

1 Like

Thanks @jocen ,

I'm not sure I did exactly what you suggested (!) but it seems to have got me to a solution.

I'm picking up the 'name' in a previous query from the 'selectedRow'. Because I want to insert a value into a cell on the same row, using the Update a Spreadsheet action type, I'm able to filter for that 'name' to find that row.

Thanks so much for taking the time to help.

1 Like