简体   繁体   中英

Issues with Triggers on Google Script

I have the following function which works perfectly fine when I run it manually.

function LastUpdate() {
  var thisSS  = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = thisSS.getSheetByName('Roster');
  var data = Session.getActiveUser().getEmail();
  var Edit = 0;
  var time = TimeStamp();
  var Row;
  Row = findInColumn("L", data);
  Edit = checkEdits(Row);
  if (Edit == 1)
  {
    sheet.getRange(Row,20).setValue(time);
  }
}

I set up a trigger manually by going to Resources -> Triggers and selected the above Function to execute onEdit . Basically, whenever a cell in the sheet is edited, I want to automatically trigger this function to execute. I am not sure what the issue is !

Any help would be much appreciated.

EDIT - I tried to do this and this also does not work

function onEdit(e)
{
LastUpdate ()
}

Why don't you use the simple onEdit trigger instead of the installed trigger? Since you're looking for the latest edit made by the active user that might be a much easier, faster and more stable solution.

function onEdit(e){
  var range = e.range; //edited range

  range.getColumn();
  range.setValue(); 
  //etc

}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM