title: Google Sheets: Session.getEffectiveUser() returns wrong values... twice
body: <p>So what I'm trying to do is to log the edits of a spreadsheet on a corresponding column.</p>
  
  <p><a href="http://i.imgur.com/P8qrJOe.gif" rel="nofollow">http://i.imgur.com/P8qrJOe.gif</a></p>
  
  <p>The last column is the autogenerated text from the embedded script.</p>
  
  <p>Here's the code:</p>
  
  <pre><code>function triggeredEdit () {
    // set sheet variables
    var activeSheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
    var activeRange = activeSheet.getActiveRange();
  
    // last updated
  
    // LAST EDITED FOR SCRIPTS (check M3 if "Latest Row Modifications")
    if (activeSheet.getRange("M3").getValue() == "Latest Row Modifications") {
      for (var i = 1; i &lt;= activeRange.getHeight(); i++) {
        // modified TL column
        if (activeRange.getCell(i, 1).getRow() &gt; 4 &amp;&amp; activeRange.getColumn() &gt;= 6 &amp;&amp; activeRange.getLastColumn() &lt;= 6) {
          activeSheet.getRange(activeRange.getCell(i, 1).getRow(), 13)
          .setValue(Session.getEffectiveUser() + "\n" + Utilities.formatDate(new Date(), "GMT", "dd MMM YY, HH:mm:ss"));
        }
        // modified TLC column
        else if (activeRange.getCell(i, 1).getRow() &gt; 4 &amp;&amp; activeRange.getColumn() &gt;= 8 &amp;&amp; activeRange.getLastColumn() &lt;= 8) {
          activeSheet.getRange(activeRange.getCell(i, 1).getRow(), 14)
          .setValue(Session.getEffectiveUser() + "\n" + Utilities.formatDate(new Date(), "GMT", "dd MMM YY, HH:mm:ss"));
        }
        // modified edit column
        else if (activeRange.getCell(i, 1).getRow() &gt; 4 &amp;&amp; activeRange.getColumn() &gt;= 10 &amp;&amp; activeRange.getLastColumn() &lt;= 10) {
          activeSheet.getRange(activeRange.getCell(i, 1).getRow(), 15)
          .setValue(Session.getEffectiveUser() + "\n" + Utilities.formatDate(new Date(), "GMT", "dd MMM YY, HH:mm:ss"));
        }
        // modified QC column
        else if (activeRange.getCell(i, 1).getRow() &gt; 4 &amp;&amp; activeRange.getColumn() &gt;= 11 &amp;&amp; activeRange.getLastColumn() &lt;= 11) {
          activeSheet.getRange(activeRange.getCell(i, 1).getRow(), 16)
          .setValue(Session.getEffectiveUser() + "\n" + Utilities.formatDate(new Date(), "GMT", "dd MMM YY, HH:mm:ss"));
        }
      }
    }
  }`
  </code></pre>
  
  <p>The function triggeredEdit is run through a project trigger, which is also dynamically created in another function. As you can see in the gif, it seems like the triggeredEdit is called twice (since it changes twice). What's worse is that the correct email to be displayed is the first one, but then it gets replaced with the wrong one.</p>
  
  <p>How do I go around fixing this? I'm quite stuck with this problem.</p>