Hi everyone!
I'm building a simple CSV-upload driven frontend for SendGrid's email validation API tool.
I was following this example documentation, but I can't seem to get the script to make the query run for each row.
This is the application:
This is the script:
var rows = fileInput1.parsedValue;
var errors = '';
var total = table1.displayedData.length;
function runQuery (i) {
// Update the statusText with the current progress
statusText.setValue(i.toString() + '/' + total.toString())
if (i >= rows.length) {
console.log('Finished running all queries');
return;
}
console.log('Running query for row', i);
query1.trigger({
additionalScope: { i: i }, // This is where we override the `i` variable from step 2!
// You can use the argument to get the data with the onSuccess function
onSuccess: function(data) {
runQuery(i + 1);
},
onFailure: function(error) {
// Update the errorsText with all the errors encountered
errors += 'Found error at line ' + i.toString() + ': ' + error + '\n\n';
errorText.setValue(errors);
runQuery(i + 1);
}
});
}
runQuery(0);
And finally, this is the configuration for the SendGrid query:
Any help would be much appreciated!