-
Goal: I am creating a simple crud app.
-
Steps: Create update script
-
Details: I am getting the same issue as detailed in this previous closed post: Retool GUI Query to Update a Single Record Not Working as Expected
-
I did some troubleshooting with the data and confirmed that I do not have any duplicate keys and the data is unique for each row. Is there any other condition that would cause this 422 status code even though no duplicate keys or data are present? I only have about 300 records so this is a small dataset.
-
For testing I deleted down to 5 records and I get the same error. Any recommendations? I also selected option in the code GUI for Bulk Update via primary key... although in my use case no record should have same data that requires bulk updating. The naming of that operation is not quite clear to me.
Hi @hexx ,
Could you please share some print screens of the query?
I've tried using the UPdate Existing Record and Bulk Update vi Primary Key. Here are the screenshots. Nothing special about them.
I deleted down to one record to test yesterday and I get the same error.
It seems like something is cached. Is there a way to refresh the app somehow? With only one record in the db table it thinks there are 7 records that are duplicates which is not the case.
Hi @hexx ,
In the array of records to update, you should pass the data like this:
[
{
"first_name": "James",
...
}
]
Instead of this format:
[
{
"key": "first_name",
"value": "James"
}
]
Feel free to ask if you need further assistance or have additional questions. We're here to help!
The array format was autogenerated when I set it based on the documentation example to update_customers.changeset. If I need manually code that then that's fine. How can one explain the same result using the update existing record option?
So for manually coding the array. How do I reference the value from the text fields within the array? Hardcoding values is not the way.
I forgot to mention that I am using self-hosted version 3.75.6 and not cloud.
@ZeroCodez I figured it out. Thanks for leading me in the right direction. I had to structure the array like this and now I don't have any errors and the records update as expected. After the fact I realized that this is documented here: Write data to SQL databases | Retool Docs. I didn't notice it the first time I looked at the documentation. Too many words on the page