Adding selected rows in a table to a new Database Table

Hello, I have built an application whereby I retrieve a filtered list of records from SQL Server TABLE-A and display it to a user in a table object (table_selected) through ReTool.

I wish the user to be able to select multiple rows in the table on the screen (table_selected), and then click a SUBMIT button to add the selected rows to a new TABLE-B in SQL server.

I have been playing around with the table_selected.selectedRow.data property but I cannot for the life of me figure out how to change that data into the appropriate JSON required in a bulk insert query for my database TABLE-B.

Any tips or how to guides would be appreciated.

Bonus points for how to translate different field names :slight_smile:

Thanks

Hey @eneko! Could you share a screenshot of the data structure of that .selectedRow.data property in the left panel of the editor (opened in the top middle)?

Also, do you have the option to allow selecting multiple rows enabled in the table component? I think that should structure the property as an array of objects which is what that bulk insert query is expecting in the GUI mode.

Just to close this one out, I ended up needing to write some javascript to loop through my selected table records and construct a transformed JSON string to pass through to the bulk insert query due to the changes in field names and mappings I needed to do.

Example:

 while (i < table_customers.selectedRow.index.length) {  

    text_json += "client_email" : "'+table_waitlist.selectedRow.data[i].Email+'", .... etc

}
1 Like