I've been using OnEdit
for some time and its been working great - however just now ive came accross a problem - basically when column 6 (f) is edited I want it to check the value - if it is "In Progress" I want it to then run a function to send an email, when I debug this - it works great exactly as I want it to, however when im not debugging it never seems to run.
var summary = ss.getSheetByName("Summary")
var data = summary.getRange(4, 1, summary.getLastRow(), summary.getLastColumn());
var learnerObjects = getRowsData(summary, data);
var lastrow = summary.getLastRow();
function onEdit(e){
var sheet = e.source.getActiveSheet();
var CellRow = sheet.getActiveRange().getRow();
var CellColumn = sheet.getActiveRange().getColumn();
if (sheet.getSheetName() == "Summary"){
if (CellColumn == 6){
var learner = learnerObjects[CellRow-4];
var status = learner.status;
if (status == "In Progress"){
var enrolmentdate = learner.enrolmentDateDdmmyyyy;
var surname = learner.surname;
var firstname = learner.firstName;
var qualification = learner.qualification;
var company = learner.company;
messagePT3 = firstname + " " + surname + " from " + company + " doing " + qualification + " has been added to your tracker.";
sendTrackerEmail(messagePT3);
SpreadsheetApp.getActiveSpreadsheet().toast('Email has been sent to Assessor regarding new learner', 'Assessor Notified', 3);
}
}
}
}
This is the main code for it, when debugging as I say it works fine, however when im not debugging it never seems to be triggered, is there any other ways for me to do this?
I have data validation on column F however this limits the cells to "Completed", "Withdrawn", "Suspended" or "In Progress" - this shouldnt have an effect should it?
I know that onEdit
is being triggered as I use it for monitoring changes to certain parts of the spreadsheet.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…