Upsert edited values in retool table into retool database

Hey all,
I have created a retool database. On top of that I want to create a CRUD using the Retool App functionality.
(I know that its possible to edit the data directly in the retool database view, but I would like to have more control on the updates and add some additional functionalities for the users)

Within the Retool App I have created a table view, additionally I have allowed for a couple of attributes that they are editable.

I would like to allow the users to edit the fields directly in the table view and synchronise / update this directly within the retool database.
For this I have created a "update" code snipper which is triggered by the event handler if the user is change the value of the input.

However, the code is not able to "receive" the input the customer does, it always stays empty.

See screenshot attached.

Happy to receive any help or support.

Thanks,
Alex

Hi there @alex, and welcome to the forum!

Here's a nice short tutorial from another forum member on how to use the table's changeSetArray together with Retool's GUI. Also, see here my post to another user with regards to primary keys and the event trigger you may want to choose (e.g. save button vs a change cell)

You're currently using selectedRow which won't show the edits made to fields within the row.

If you aren't using it already, I find right clicking on any component and selecting "view state" really helpful to understand all the variables I can use across my apps and components.

Hope this helps!

Hey Miguel,
I'm not 100% sure if this helps me right now.

I'm using the SQL way and not the GUI to insert the data, are you saying that its not possible with the SQL way?

Additionally, I cannot really see a proper way in the articles what "function" to use in the SQL in order to get the data from the actual row.
Could you point me to that, if possible?

Thanks a lot.
Alex

I have played around a bit more with your approach, if I always select the "first item" of the array, then I can do only one change, and if I do a second change later it just rewrites the first item.

(see screenshot)

Can this be done somehow that the update runs every time on the "correct" row ?

I have resolved it now.
Using the bulk update functionality.
Thanks for your help!

2 Likes

Sorry if I was not very clear from the start, but I'm glad you got there in the end!

2 Likes