I have a google sheet that has an auto refreshing IMPORTXML function on it based on a timed trigger and am trying to write a script that will auto email a notification alert when it retrieves a row with a "HELP" message type.
I compiled this script based on some examples I found. I have tested it and it works fine with manually entered data with an onEdit installable trigger but from my testing (and based on research) I need to use the onChange trigger to have the IMPORTXML trigger the script.
However, when I set the script to a onChange installable trigger, the script doesn't seem to execute either automatically with the IMPORTXML loading data or by me manually entering it on the sheet.
Am I hitting some limitation of Good Apps Script? This is my first time using it (and JavaScript)
function helpAlertEmail(e)
{
if (e.range.columnStart !== 5 || e.value !== 'HELP' && e.value !== 'HELP-CANCEL') return;
var ss = e.source.getActiveSheet()
var details = ss.getRange(e.range.rowStart, 1, 1,11).getValues()[0];
var headers = ss.getRange(1, 1, 1, 11).getValues()[0];
var subject = "SPOT BEACON ALERT: " + details[2] + " Sent a " + details[4] + " Message at " + details[9];
var body = "SPOT Beacon " + details[2] + " (" + details[1] + ") Sent a " + details[4] + " Message at " + details[9] + "\n\n";
var email = "[email protected]";
var cols = [0, 4, 5, 6, 9, 10];
for (var i = 0; i < details.length; i++)
{
if (cols.indexOf(i) === -1) continue;
body += headers[i] + ": " + details[i] + "\n"
}
body += "\n\n\n Please do not respond to this email as it is automatically generated by an account that is not checked.";
MailApp.sendEmail(email, subject, body, {noReply:true});
}