-
Goal: bulk insert to a table using selected items from a multiselect listbox and values from dropdowns
-
Steps: I've searched multiple resources online for the correct syntax
-
Details: I am struggling with the map() function ( I am very new to javascript but have experience with VB and Python)
-
Screenshots:
I'm using Redshift, and I have a table named tblISCI_Override with three fields, WeekOf, BadISCI and GoodISCI. The form on the right side of my image shows the bad ISCI (a value not found in another table), a dropdown of good values, and the weeks the bad values were found. I am trying to populate the tblISCI_Override table with these inputs but I am not able to get the javascript syntax correct to create the array of values that will be inserted.
I have zero days' experience with javascript but about a year's worth experience with Python and sadly 20 years experience with VB/VBA. I'm primarily a database developer.
Hey there @chris_casualprecision,
So if I'm understanding correctly the labels will be different but badisci and goodisci will remain constant, right?
If so, the following may help:
lstBadISCIDates.selectedLabels.map(x => {
const txtinput1_value = txtinput1.value;
const cboGoodISCI_value = cboGoodISCI.value;
return {
weekof: x.label,
badisci: txtinput1_value,
goodisci: cboGoodISCI_value
};
});
this got me a little further, but I'm stuck with an error stating "Records must be an array". This is what I have in the query definition where I'm trying to specify the bulk records to insert:
Javascript in GUI mode needs to be fully wrapped in one set of double curly brackets
Does it work if you remove the {{}} around tblBadISCIs.selectedRow.isci
and cboGoodISCI.value
, and then wrap the whole code in {{}}
Also, it looks like you need to add return {
after the arrow (=>
) and a space and closing }
before the closing parentheses