title: Add-on Trigger not running, how can I troubleshoot
body: <p>My add-on creates a trigger that runs every hour.  It works when I run it from the script, but it does not seem to work when published as an add-on.   I am wondering what is the best way to trouble-shoot this.</p>
  
  <p>Below is the script that runs on the hour.   Maybe there is something in there that might help figure out what is going on.</p>
  
  <pre><code>function updateDay(){
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var sheets = ss.getSheets(); 
  
    for (i in sheets){
      var sheetName = sheets[i].getName();
      var cella2 = sheets[i].getRange(1, 2).getValue();
      if (sheetName == cella2){
  
        //check if weekend
        var cellA3 =  new Date(sheets[i].getRange(3, 1).getValue());
        if (cellA3 == "-"){
          sheets[i].deleteRow(3);
          SpreadsheetApp.flush();
          cellA3 =  new Date(sheets[i].getRange(3, 1).getValue());
        }
  
        var cellA3F = Utilities.formatDate(cellA3, "EST", "MM/dd/yyyy");
        var today = new Date();
        var todayF = Utilities.formatDate(today, "EST", "MM/dd/yyyy");
  
        if (cellA3F &lt; todayF){
  
          //write to Log
          var sendToLog = [];
          var logSheet = ss.getSheetByName("Log");
          var logDate = sheets[i].getRange("A3").getValue();
          var sheetLastColumn = sheets[i].getLastColumn();
  
          sendToLog.push(logDate);
          sendToLog.push(sheetName);
          for (var j=2; j&lt;sheetLastColumn+1; j++){
            var colHeading = sheets[i].getRange(2, j).getValue();
            var colName = sheets[i].getRange(3, j).getValue();
            sendToLog.push(colHeading+":"+colName);
          }
  
  //        ["12/16/14","Lab1","Per1:bj","Per2:Sara"];
          logSheet.appendRow(sendToLog);
  
          //add new day
          var lastDay =  new Date(sheets[i].getRange(sheets[i].getLastRow(), 1).getValue());
          var dayOfWeek = Utilities.formatDate(lastDay, "EST", "EEE");
          if (dayOfWeek == 'Fri'){
            var nextMon = new Date(lastDay);// This needs to be two lines for some reason.
            nextMon.setDate(lastDay.getDate()+3);
            sheets[i].appendRow(["-"]);
            sheets[i].appendRow([nextMon]);
          } else{
            var nextDay = new Date(lastDay);// This needs to be two lines for some reason.
            nextDay.setDate(lastDay.getDate()+1);
            sheets[i].appendRow([nextDay]);
          }
          sheets[i].getRange("a:a").setNumberFormat('DDD, MM/dd');
  
          //remove tody
          var dayOfWeek2 = Utilities.formatDate(cellA3, "EST", "EEE");
          if (dayOfWeek2 == 'Fri'){
            sheets[i].deleteRow(4);
          }
          sheets[i].deleteRow(3); 
        }
      }
    }
    // for testing
    SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Log").getRange(1,4,1,2).setValues([["Last Update", new Date()]]);
  }
  </code></pre>
  
  <p>And here is the code that I use to create the trigger.</p>
  
  <pre><code>  //  Configure trigger
    var projectTriggers = ScriptApp.getProjectTriggers();
    if (projectTriggers.length == 0){
      ScriptApp.newTrigger('updateDay').timeBased().everyHours(1).create();
    }
  </code></pre>