How to update multiple rows using a multi select table

Hi,

I am really new to retool and having some trouble updating multiple records based on the user selecting multiple rows in a table.

I have created a table that displays data from my database and have successfully updated 1 row. I would like to be able to update multiple rows but unsure how to set this in the GUI Mode.

I've enabled multiple rows to be selected in the table but not sure how to reference this in the IN clause.

This works for 1 row:

How do i update this for multiple?

Thanks

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

You can hover on the {{}} code to view what kind of data you are passing as argument in the GUI filter. You can also open the left panel (CMD+B) to view the data structure of your components and resources so you would know how to properly refer to them. Some screenshots on your table structure would be helpful to pinpoint on how you are accessing the array of ID.

I'm assuming you are using a Google Sheet Resource here, might want to check up on how to bulk update it. With the resource you are using now, it seems it will update all the specified ID by the single value you place and not dynamically update the value for each ID. If this is your use-case, then it should be fine.

Regards

Hi,

Thanks for your prompt reply.

I'm using an oracle DB as a resource and populating the table based on a select statement.

When i don't have multiple rows selected for the table and I hover over the resource I get the ID.

When I enable multiple rows and I hover over the resource I get 'undefined' Is there a different way of selecting the data when multiple rows are selected?

Thanks

Hi @Terry,

I see. You can hover on the TransactionTable.selectedRow.data and it'll show you that it has a structure of Array<object>. What you want is to iterate over TransactionTable.selectedRow.data to provide you a list of ID. You can do either of the following:

  1. {{ formatDataAsObject(TransactionTable.selectedRow.data).ID }}
  2. {{ TransactionTable.selectedRow.data.map(x=>x.ID }}

Either of those should work on your filter argument. Lemme know how you go with that

Hi,

Thanks for your suggestions. Think i'm understanding this better now.

I have tried both of those options and get errors.

Is there a syntax error?

Thanks

@Terry, try putting space in between the code and the brackets.
i.e.
{{ formatDataAsObject(TransactionTable.selectedRow.data).ID }}

Hi,

That worked thanks for your help.

When I use this in SQL mode i get the following error:

Trying to pass in the selected ID's to populate another table.

Can this only be used in GUI mode?

Thanks

Hi @Terry,

That error code is an Oracle DB specific error. It's basically saying that's the wrong syntax. I'm not familiar with Oracle DB so you might want to read up on their documentation re: Working with Arrays.

Something I find similar is the Postgres syntax on this cheatsheet. You might want to try that syntax if that works for Oracle DB.

Thanks for the links will take a look