title: Apps Script to update Timestamp when data is inserted automatically in google sheet
body: <p>This code works fine when data is edited in Column 3 or being copy-pasted but if the cursor remains at column 1 at the time of the whole row being copy/pasted, it won't update and secondly, if salesforce sends data to column 3, it doesn't work that time too, please help me here.</p>
  <pre><code>function onEdit() {
    var s = SpreadsheetApp.getActiveSheet();
    var sName = s.getName();
  
    var r = s.getActiveCell();
    var row = r.getRow();
    var ar = s.getActiveRange();
    var arRows = ar.getNumRows()
    // Logger.log(&quot;DEBUG: the active range = &quot;+ar.getA1Notation()+&quot;, the number of rows = &quot;+ar.getNumRows());
    
  
    if( r.getColumn() == 3 &amp;&amp; sName == 'Sheet1') { //which column to watch on which sheet
     // loop through the number of rows
      for (var i = 0;i&lt;arRows;i++){
        var rowstamp = row+i;
        SpreadsheetApp.getActiveSheet().getRange('F' + rowstamp.toString()).setValue(new Date()).setNumberFormat(&quot;MM/dd/yyyy hh:mm&quot;); //which column to put timestamp in
      }
    }
   }//setValue(new Date()).setNumberFormat(&quot;MM/dd/yyyy hh:mm:ss&quot;);
  </code></pre>