Anna -
Anna -

Reputation: 21

Installable On edit Trigger Not Firing

I have a container-bound script attached to a Google Sheet for which I've manually added an On edit installable trigger. I'm using an installable trigger rather than a simple trigger because I want the script to run from the sheet owner's account (my account) no matter who the user is who made the edit. The script is as follows:

function checkTimecardRange() {
  var activeSS = SpreadsheetApp.getActiveSpreadsheet();
  var activeSheet = activeSS.getActiveSheet();
  var cell = sheet.getActiveCell();
  var row = cell.getRow();
  var approvalTimestamp = activeSheet.getRange("V" + row);
  var timecardRange = activeSheet.getRange("A" + row + ":V" + row);
   if(timecardRange.isBlank()==false) { 
    lockTimecardRange(timecardRange, row);
  }
}


function lockTimecardRange(timecardRange, row) {
  var protection = timecardRange.protect().setDescription('Timecard Row' + row);
  protection.removeEditors(protection.getEditors());
  if (protection.canDomainEdit()) {
   protection.setDomainEdit(false);
 }
}

It works fine when I run it manually, but the On edit trigger that I set up for it will not fire. I changed the trigger to a test script:

function log(){
  console.log("Hello worlds");
}

and that doesn't fire either. Any assistance in getting the onEdit installable trigger to fire would be greatly appreciated. The edits based on which I expect the trigger to fire are manual edits (at this point I'm just typing in random values) and they are made from the account that owns the sheet and created the scripts.

Upvotes: 0

Views: 897

Answers (1)

Anna -
Anna -

Reputation: 21

Well, it turns out that it was a glitch on Google's side. All I had to do was delete the trigger, save, then re-add the trigger without any changes, and everything worked just fine. Go figure.

Upvotes: 2

Related Questions