I must not be understanding you correctly. Currently I have the following:
query11 - pulling all device information from the organization
Switchinfo - SQL query pulling just serial numbers from query11
table1 - displaying a list of serial numbers from Switchinfo
query1 - POST REST API query with table1.data[ i ] variable in the place we need to input all the data
button1 - This runs the script from the original post.
If I reference an object like you mentioned, do I need to put in every value into that object to let the script run through each of them? I tried that by making another sql query and added a few serial numbers and it didn't work. Using your example my SQL query has Bob, Evan, Mary etc... How can I have it read only one of those at a time and move onto the next?
At this point I've tried several other options I've found online and none really seem to be working for me. I'm sure it's something simple that I'm doing wrong, but I'm lost at this point...
Example 1
table1.data.forEach(row => query1.trigger)
Example 2
const arr = SwitchInfo.value //your array of things to iterate over
const query = query1 // your query to trigger for each
const promises = arr.map((item) => {
return query.trigger({
additionalScope: {
Switchinfo: item //assignment_id would be available inside {{assignment_id}} in the target query when run
}
});
});
return Promise.all(promises)
Example 3 - This one I tried with just entering several different serial #s for the a values.
var rows = [{ a: 1 }, { a: 2 }, { a: 3 }, { a: 4 }];
function runQuery (i) {
if (i >= rows.length) {
console.log('Finished running all queries');
return;
}
var data = rows[i];
console.log('Running query for row', data);
query1.trigger({
additionalScope: {
data: data
},
// You can use the argument to get the data with the onSuccess function
onSuccess: function(data) {
runQuery(i + 1);
}
});
}
runQuery(0);