How do I get a row to update via a dropdown?

I have a table with a dropdown option:

2023-02-16 13_55_37-Window

I want the option to select and switch from Contact to Do Not Contact and vice/versa. I can click and change it, then a Save option comes up;

image

When I click it, the option change in my table, but the console says "No rows were updated". I am running a query (using GUI mode, and mySQL;

{{ Contacts.data }}
And get this error code:

  • statusCode:422
  • error:"Unprocessable Entity"
  • message:"No rows were updated."
  • data:null

I'm not great at Event Handlers; What do I need to

  • Save drop down changes to my table?
  • Find the right Event Handler?

Thank you!

Hey @runtcpip! Happy to help with this. Would you mind sharing a screenshot of the query that your Save Changes button is triggering?

Here are some docs on updating from a table in case it's helpful: https://docs.retool.com/docs/data-in-tables#editable-table-columns

The Changeset now says

{{ Contacts.bulkUpdateAction}}

and when I run it, I get:

ContactsSaveChangesHandler2: {"status":422,"message":"In order to update a record you must specify which rows to update by filling out the "Filter By" section in the Query Editor.","statusCode":422,"error":"Unprocessable Entity","data":null,"queryExecutionMetadata":{"estima...

Your link to the docs says this:

After making columns editable, you can double click on a cell to edit it. When you edit cells, changes are saved in the table's recordUpdates property. This tracks the changes you've made but it doesn't update the underlying data source that your query connects to. To save edits back to your data source, you must write an appropriate query to update your data. For example, saving changes to a PostgreSQL database can be done using a Bulk update query.

I'm using a MySQL DB and it seems to be at least saving, but I'm getting that error message still.

Can't find a way to edit that recent post, so...

{{ Contacts.recordUpdates }}

Saves to local storage, but not to the DB. I have a form attached to the table that's attached to the DB, and that saves to the DB. How do we make it update the DB like the form does?

Would you mind sharing your current query that’s not working properly? :slight_smile:

Here’s another doc on writing update queries:

https://docs.retool.com/docs/retool-fundamentals-lesson-three#1-create-a-query-that-updates-names-and-email-addresses

There are several queries across several copies of this app; This one in particular is using;

{{ Contacts.bulkUpdateAction}}

I'm looking at the documentation you linked to, and can't find any option to change anything to an Action type:

I selected the 'Add' arrow and selected Resource Query to get the preceding screen. Hitting the upper left navigation and going to the Query Library seems to open the appropriate page.

image
My table name is called Contacts, and is still considered undefined.

(My table name in my DB proper is ContactStatus, if it helps. Still Undefined.)

I did put the URL to my database, but as it's hosted as a standalone DB on AWS, * error:"Only absolute URLs are supported"

Ah, in your query, can you try changing SQL mode to GUI mode in the dropdown and let me know if that gets you any closer?

It's still considered wrong and will not save to the DB;

]

''In order to update a record you must specify which rows to update by filling out the "Filter By" section in the Query Editor.''

Since there's code in the Filter By section, what's wrong? I'm talking through support and they can see into the program; If I provide the link, can you look inside as well? (They're in a copy of this app, so you wouldn't be crossing over).

Thank you for those screenshots!\

For the error message you're seeing, it looks like it's specifically referring to your Filter by section. You're passing in {{Contacts.selectedRow.data}}, which actually returns an entire object of selectedRow data. Like this:

So to pass the actual id in, you'll need to do something more like:

{{Contacts.selectedRow.data.id}}

Similarly, for your point_of_contact field, you're likely passing in an entire data object so you'll need to key into the specific value to update with maybe something like:

{{ContactsSaveChangesHandler.data.point_of_contact}}

What is ContactsSaveChangesHandler? And are you updating your table? Are the changes persisting in the recordUpdates property (more on that here)? You can view all the underlying data of your Retool components in the State tab of the left panel.

I put
| {{Contacts.selectedRow.data.point_of_contact}}

into the filter by section, and now it's deleted some of the points of contact (or maybe it made them null values) At least it didn't throw an error!

If I put a name in the changeset section, it'll somehow update two name entries at once, but at least it updates and actually saves, so progress!

The tables are updating the deletions, but not the changes. If I provide the link, can you look inside as well? (They're in a copy of this app, so you wouldn't be crossing over).