google-sheetsgoogle-apps-scripttriggers

Why has my onEdit Script stopped triggering?


Damien was kind enough to provide the script below (https://stackoverflow.com/a/79606172). It worked beautifully. Now, a couple of days later, it doesn't.

What changed:

I re-named the spreadsheet file?

What I've tried:

re-pasted script into existing script, made new script and pasted. Worksheet name has not changed. Nor has the location of onEdit cell to monitor.

 function onChange(e) {
  
  const range = e.range;
  const activeSheet = e.source.getActiveSheet().getName();
  const conditions = [
    activeSheet === 'MATCHUPS',
    range.getRow() == 47,
    range.getColumn() == 16
  ]
  if (conditions.every(c => c === true)) {
    var spreadsheet = SpreadsheetApp.getActive();
    spreadsheet.getRange('L49').activate();
    spreadsheet.getRange('A49:A74').copyTo(spreadsheet.getActiveRange(), SpreadsheetApp.CopyPasteType.PASTE_NORMAL, false);
  }
}

Solution

  • The code included in the question doesn't have the same function name as the referred answer.

    The function name should be onEdit or you have to create a installable trigger and set onChange as handler function, but onChange is an terrible name for an handler function for an installable on edit trigger.

    The simple fix is to use onEdit, which is the reserved function name for the on edit simple trigger.