0

I have seen similar questions but none of the the solutions worked for me. I have this simple code that just compare a given date to today's date. If today is the greater than the Given date, script returns "ON TIME" and should paint cell's background in green. Else, returns "LATE" and print cells background in red. I can get the returned value, but when I put the line to pain the cell, I receive the error thata I don't have permission to call setbackground.

I tried what I saw in No permission to call msgBox in Google Apps Scripting .


  var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  var currentCell = sheet.getCurrentCell();
  var mtoday= new Date();

  if ( mtoday < DtEnd ){
    currentCell.setBackground("green");
    return 'ON TIME';
  }

 if ( mtoday > DtEnd ){
    currentCell.setBackground("red");
    return 'LATE';   
 }


  return;

}```

ERROR MESSAGE: You don't have permission to call setBackground (line...)
Leandro Guedes
  • 111
  • 1
  • 2
  • 14

1 Answers1

1

I found the proper answer here:

https://webapps.stackexchange.com/questions/80261/fixing-permission-problems-in-cross-spreadsheet-import-when-using-apps-script

Hope this can help others. Thank you!

Leandro Guedes
  • 111
  • 1
  • 2
  • 14