Hi Retool Community,
I am trying to use data in a database to populate dropdown lists on a form I am creating and I have a couple of issues.
When I convert the DB query from an object to an array using the FormatDataAsArray function I end up with an array that consists of a key-value pair.
The key-value pair is as follows
[{"customer_info_data":"Head Office"},{"customer_info_data":"Remote Office"},{"customer_info_data":"Data Centre"},{"customer_info_data":"Other"}]
My first thought was to use JS to further manipulate the data and while I have this working on a standard HTML page I cannot work out how to use that in Retool, I've included a screenshot of my JS and also how I am trying to retrieve that in Retool (see the red circle in the image.)
My next thought was to move the project forward and just explicitly call each value from the key-value pair, so in the Values box I added the following:
[{{Location_Type.data[0].customer_info_data}},{{Location_Type.data[1].customer_info_data}},{{Location_Type.data[2].customer_info_data}},{{Location_Type.data[3].customer_info_data}}]
While that looks OK when I test the page and try to use those values in a SQL insert query it seems extra apostrophes (') and whitespace are added. Below is the insert query from the SQL logs.
insert into customers (cust_name, cust_loc_type, cust_loc_seats, cust_loc_util) values ( 'Test Customer' , ' 'Head Office' ', ' '500-999' ', 'Med-High')
I'm at a bit of a loss on how to move forward now so any help with this would be greatly appreciated. Also, assume no prior knowledge of JS, Retool and generally the whole thing!!!