onEdit simple trigger never seems to be triggered

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.


The onEdit() trigger is a so called "simple trigger" that has a limited field of action. Since it runs automatically and silently under the authority of the active user it can't do anything that requires authorization, for example it can't send emails !

The solution is simple : change your function name to something else (myOnEdit for example) and set an installable onEdit trigger to run that function.(menu ressource/current script trigger/create new trigger in the script editor.)

This time it will be executed as you (you'll be sending the emails) when anyone edits the spreadsheet.

Documentation on that subject is available here.