title: Google Apps Script - Make onEdit() recognize setValue() changes
body: <p>I have a Spreadsheet with some functions. One of them is a onEdit(event) function that copies some values to other sheets based on conditions. This is the code (simplified but with the important parts intact):</p>
  
  <pre><code>function onEdit(event) {
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var s = event.source.getActiveSheet();
      var r = event.range;
      if(s.getName() === "Lista" &amp;&amp; r.getColumn() === 9 &amp;&amp; r.getValue() === "Posicionada") {
        var sheetname = s.getRange(r.getRow(),3).getValue();
        var columnRef = s.getRange(r.getRow(),4).getValue();
        var row = s.getRange(r.getRow(),5).getValue();
        var targetSheet = ss.getSheetByName("Mapa " + sheetname);
        var headers = targetSheet.getRange(1, 1, 1, targetSheet.getLastColumn());
        for (var i = 0; i &lt; headers; i++) {
          if (headers[i] === columnRef) {
            break;
          }
        }
        var column;
        if (columnRef === "A1") {
          column = 2;
        }
        else if (columnRef === "A2") {
          column = 3;
        }
        else if (columnRef === "B1") {
          column = 4;
        }
        else if (columnRef === "B2") {
          column = 5;
        } 
        if (sheetname === "N2") {
          row = row - 30;
        }
        if (sheetname === "N3") {        
          column = column - 10;
          row = row - 42;
        }
        targetSheet.getRange(row,column).setValue(s.getRange(r.getRow(), 1, 1, 1).getValue()); 
      }
  }
  </code></pre>
  
  <p>The code works as it should when I manually edit the cell. But, I have a code that edit the cell when the user press a button in a sidebar, this is the code:</p>
  
  <pre><code>function positionMU(){
    var ss = SpreadsheetApp.getActiveSpreadsheet();
    var cell = ss.getActiveCell().activate();
    var cellLevel = cell.offset(0,2);
    var cellLetter = cell.offset(0,3);
    var cellNumber = cell.offset(0,4);
    var cellStatus = cell.offset(0,8);
    var dbq = "Posicionada";
    var fora = "Pendente de recebimento";  
    if (cellStatus.getValue() == "Aguardando posicionamento"){
        cellStatus.setValue(dbq);    //attention in this line  
    }
    else if (cellStatus.getValue() == "Aguardando saída"){
        cellStatus.setValue(fora);
        var cellExitDate = cell.offset(0,6);
        cellExitDate.setValue(getDate());
    }
  }
  </code></pre>
  
  <p>As you can see, this function change the cell content with setValue(), but, when I use this function, the value of the cell changes, but the onEdit() trigger doesn't work.</p>
  
  <p>How can I make the onEdit() trigger recognize changes made with setValue()?</p>