We're now to Retool and have just started playing in readiness for building a few solutions for our internal business units. We've been testing the new Table component and have got a snag which we can't seem to find a direct solution for in the docs, forum or video tutorials.
Our use case is that we have data which comes from third party platforms into our staging database. Some records need manual review to ensure the transactions coding is correct. We have got this working fine for a single record.
What we're struggling with is how to update a number of selected records with a single value aka, update these x number of records with this source code. We're trying to use the "Bulk update via a primary key" and are using the "table.selectedrows" array to get the selected row but we can'r figure out how to update x field within the selected rows for the target database table with the entered value.
Could anyone point us the right direction please?.. thanks..
We encountered a similar issue for filling in multiple entries with a single data point. There are definitely MUCH better ways to implement the solution here but what we landed on was a javascript query to loop through the row selections and trigger an update/create to our table as needed. This was mostly because there was necessary logic for determining how to handle new vs update entries.
Here, fillInfoXfrm is a transformer which is handling the mapping of data for two different tables (which could both have the single data point updates addressed). Here's the basic breakdown with my custom mappings redacted:
At the end we return the final array, filtered by unique primary key.
The loop processes all of the selected rows from both tables one at a time which isn't great for overhead but allowed us to insert some branching logic along the way.
The button triggers the loops, which is reading the actively transformed data that is updated after the row selections are made. The loop branches to the proper single entry query to update or create the new mapping data.
We've checked the table and the SOURCE_CODE data type is actually "VARCHAR" and have tried with a Text Input Component also and with AS_VARCHAR but still the same issue?!.. v.odd
I wonder if this has more to do with the IN clause.
You can try to use WHERE ID = ANY({{ table.selectedRowKeys }})
This might be related to the prepared statements option on the resource. Disabling prepared statements might get it working, but at the cost of higher risk of queries borking the whole DB.