0
votes

I am using below code to get the last update date in Column B. Now when I protect the column B (because I don't want the other users to make any changes) and share this sheet with other users the update is not happening.

I would appreciate your help.

function onEdit() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheetName = "Sheet1";
  var s = SpreadsheetApp.getActiveSheet();
  if (s.getName() !== sheetName) return;
  var r = s.getActiveCell();
  if( r.getColumn() != 2 ) { //checks the column
    var row = r.getRow();
    var time = new Date();
    time = Utilities.formatDate(time, "GMT+5", "dd/MM/yy, hh:mm:ss");
    SpreadsheetApp.getActiveSheet().getRange('B' + row.toString()).setValue(time);
  };
 };
1

1 Answers

0
votes

Instead of using an simple trigger use an installable trigger.

The above is because simple triggers are only able to execute tasks that don't require authorization.