登录在Google电子表格中修改了一行的用户?

时间:2018-08-09 16:57:23

标签: google-apps-script google-sheets triggers

我有以下代码在行的最后一个单元格中写入最后一个编辑日期和时间:

function onEdit(event)
{
  var sheet = event.source.getActiveSheet();

  // Note: actRng = return the last cell of the row modified
  var actRng = event.source.getActiveRange();
  var index = actRng.getRowIndex();
  var cindex = actRng.getColumnIndex();

  // Note: date = return date + time
  // Note: user = return the user email
  var dateCol = sheet.getLastColumn();  
  var lastCell = sheet.getRange(index,dateCol);
  var date = Utilities.formatDate(new Date(), "GMT-0300", "dd-MM-yy HH:mm");

  //var user = event.user;  // Note: event.user will not give you collaborator's Id
  var user = Session.getEffectiveUser();

  // Note: setcomment = Inset a comment with the user email
  // Note: setValue = Insert in the cell the date + time when this row was modified
  lastCell.setValue("'" + date).setComment(user);
}

这还会在最后一个单元格上注释修饰符电子邮件。但是,这只是注释所有者的电子邮件ID,而不是共享共享者和进行更改的人的电子邮件ID。

如何记录上次编辑行的人的电子邮件ID?

0 个答案:

没有答案