networkcat

onEdit(event).gs

Mar 1st, 2019 (edited)
6
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function onEdit(event)
  2. {
  3. var timezone = "UTC+!NUMBER";
  4. var timestamp_format = "EEEE dd MMMM yyyy hh:mm:ss"; //Custom date format
  5. var updateColName = "post-sent"; // Responder
  6. var timeStampColName = "post-receive"; // Output
  7. var sheet = event.source.getSheetByName('!SHEETNAME');
  8.  
  9.  
  10. var actRng = event.source.getActiveRange();
  11. var editColumn = actRng.getColumn();
  12. var index = actRng.getRowIndex();
  13. var headers = sheet.getRange(1, 1, 1, sheet.getLastColumn()).getValues();
  14. var dateCol = headers[0].indexOf(timeStampColName);
  15. var updateCol = headers[0].indexOf(updateColName); updateCol = updateCol+1;
  16. if (dateCol > -1 && index > 1 && editColumn == updateCol) {
  17. var cell = sheet.getRange(index, dateCol + 1);
  18. var date = Utilities.formatDate(new Date(), timezone, timestamp_format);
  19. cell.setValue(date);
  20. }
  21. }
RAW Paste Data