How to put a username to the cell , who made the last modification of the row?

前端 未结 1 1861
南方客
南方客 2021-01-26 04:33

I have a code, it inserts the last modification to the current row in the specified cell. And i need to insert the time in one cell, and the name of the user who made ​​the chan

相关标签:
1条回答
  • 2021-01-26 05:12

    Here is a code I use to track changes on a spreadsheet, the onEdit() function is a simple trigger, the alert() function is an installable onEdit trigger since it need authorization.

    function onEdit(event){
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var sh = event.source.getActiveSheet();
      var r = event.source.getActiveRange();
      r.setComment("Last modified: " + (new Date())+' by '+Session.getActiveUser());
      ss.toast('Dernière cellule modifiée = '+r.getA1Notation()+' par '+Session.getActiveUser());
    }
    
    function alert(){
      var ss = SpreadsheetApp.getActiveSpreadsheet();
      var cell = ss.getActiveCell().getA1Notation()
          if(Session.getActiveUser()!='me@mymail.com'){
      MailApp.sendEmail('me@mymail.com', 'Modification dans le planning', 'la case '+cell+' du document a été modifiée par '+Session.getActiveUser());
    } 
    }
    
    0 讨论(0)
提交回复
热议问题