title: Can't get getActiveSheet() from undefined
body: <p>I'm trying to copy a row from sheet "Name1" to sheet "Name2" when entering "ok" in cell 1 (column 1) but I couldn't fix this error in the title (Cannot call method "getActiveSheet" from undefined). I have tried all those commented lines but no luck, I'm editing the cell and enter "ok" in that cell but not working. </p>
  
  <pre><code>   function onEdit2(e) {
        //var ss = SpreadsheetApp.getActiveSpreadsheet();
      var ss = e.source;
       //var s = SpreadsheetApp.openById("1yAJY3gO46A7Wr_fYtVHAB_wSElUdG2kkiH1clRg9o8k").getSheetByName('Name1');
     var s = ss.getActiveSheet();
     var r = e.source.getActiveRange();
  
    if(s.getName() == "Name1" &amp;&amp; r.getColumn() == 1 &amp;&amp; r.getValue() == "ok") {
       var row = r.getRow();
       var numColumns = s.getLastColumn();
       var targetSheet = ss.getSheetByName("Name2");
       var target = targetSheet.getRange(targetSheet.getLastRow() + 1, 1);
       s.getRange(row, 1, 1, numColumns).moveTo(target);
       s.deleteRow(row);
   }
  }
  </code></pre>
  
  <p>the error I'm getting is </p>
  
  <pre><code>  TypeError: Can not call method "getActiveSheet" from undefined. (Row 135).
  </code></pre>
  
  <p>I edited those first lines to those</p>
  
  <pre><code>     var ss = SpreadsheetApp.getActiveSpreadsheet();
        // var ss = e.source;
        //var s = SpreadsheetApp.openById("1yAJY3gO46A7Wr_fYtVHAB_wSElUdG2kkiH1clRg8o9k").getSheetByName('Lista');
    var s = ss.getActiveSheet();
     var r = e.source.getActiveRange();  // I get error now here can't call getactiverange from undefined . 
  </code></pre>