OnEdit function not working for shared users

谁说我不能喝 提交于 2021-02-11 13:35:16

问题


I have the following OnEdit script in a Google spreadsheet that inserts a timestamp when a checkbox is edited. The action is preformed when I make the edit, but does not work when the edit is made by another user. Any help is appreciated.

function onEdit(e) {
  
  addTimestamp(e);
  
}
  

function addTimestamp(e){
  //variables
  var startRow = 3;
  var targetColumn = 6;
  var ws = "MasterList";
  
  //get modified row and column
  var row = e.range.getRow();
  var col = e. range.getColumn();
  
  if(col === targetColumn && row >= startRow && e.source.getActiveSheet().getName() === ws){
    e.source.getActiveSheet().getRange(row,19).setValue(new Date());
  }  
}

回答1:


I have seen several cases having problems using chaining with active methods that might be difficult to reproduce.

Try replacing

e.source.getActiveSheet().getName()

by

e.range.getSheet().getName()

Related

  • Why Class Range getValues sometimes returns [[]] when chained to Class Sheet getActiveRange?



回答2:


The onEdit() function will run whenever the spreadsheet is edited. And you can check any failures under Tools > Script editor > View > Executions.

The reason that it fails to work under shared users editing is those users do not have permission to edit the target cell. It means you had set the protection of the cell.



来源:https://stackoverflow.com/questions/63398087/onedit-function-not-working-for-shared-users

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!