I searched, and there are similar questions, but nothing is quite right for my situation. I have a feeling I am going about this in a needlessly complicated way, but it was all I could think of.
- Goal: User clicks multiple rows from this table, selects a value from a select element within a modal, and that updates multiple rows in a database table called plate. Database is within the Retool resources.
The "Status Name" is supposed to update.
- Steps:
- Select a status from the drop down.
- Run this query:
update plate
set plate_status = {{ statusSelect.selectedItem.id }},
last_updating_user = 'UNKNOWN',
last_updated_time = now()
where serial_code in (selectedPlates.value)
;
and "selectedPlates" is from this Transformer
var selectedNumbersArr = [];
selectedNumbersArr = selectedNumbersArr.concat({{ plateInfoTable.selectedRows }}.map( it => {return {serialNo : it.serial_code}}));
var selected = "";
for(var i = 0; i < selectedNumbersArr.length; i++){
selected += " '" +selectedNumbersArr[i].serialNo +"' ,";
}
return selected.substring(0,selected.length - 1);041
It produces working SQL, e.g. update plate set plate_status = 4, last_updating_user = 'UNKNOWN', last_updated_time = now() where serial_code in ( '0000011112222' , '123456789' , '222222' ) ;
This query runs without errors, but it fails to update anything.
I tried to do this through the GUI tab and the "Bulk Update Records through Primary Key", but was even more clueless on how to do that.