Hi,
I am still fairly new to ReTool so please bare with me.
I am trying to impliment the following JS code, such that it updates my DB with the two global values. I used additionalScope to get the values correct. However, when I run it I keep getting the last indexed value in the array. I believe I set the nested While loops correctly, but I could be wrong (also fairly novice at JS).
Note, all the console logs show a list of all the corrected values for both variables, but they are not translating into the SQL query. The SQL query is just a simple INSERT INTO / Value query.
function uniqueFilter(value, index, self) {
return self.indexOf(value) === index;
}
var currentTime = new Date();
var yr = currentTime.getFullYear();
var borrowers = list_active_borrowers.data.borrower_id.filter(uniqueFilter);
var numBorrowers = list_active_borrowers.data.borrower_id.filter(uniqueFilter).length;
var reports = list_reports.data.report_type.filter(uniqueFilter);
var numReports = list_reports.data.report_type.length;
var x = 0;
var i = 0;
var y = 0;
while (x < numBorrowers) {
selectedBorrower.value = borrowers[x];
console.log(selectedBorrower.value)
while (i < numReports) {
selectedReport.value = reports[i];
console.log(selectedReport.value)
while (y < 5) {
query21.trigger({additionalScope:{selectedBorrower, selectedReport}});
y++
}
y = 0
i++
}
i = 0
x++
}```