Home > Software engineering >  Issue with onEdit(e) not triggering with BetterLog
Issue with onEdit(e) not triggering with BetterLog

Time:10-21

I'm trying to trigger the function onEdit(e) but i got the following error:

Exception: You do not have permission to call SpreadsheetApp.openById. Authorisations required : https://www.googleapis.com/auth/spreadsheets at setLogSheet_(Code:384:38) at useSpreadsheet(Code:43:5)*

I'm using BetterLog library, and it seems to come from the following code line:

var Logger = BetterLog.useSpreadsheet(sheetId);

When i remove from my code this specific line it works well. After looking for a solution, i tried to add the following annotation

/**
 * @NotOnlyCurrentDoc
 */

but didn't work...

CodePudding user response:

SpreadsheetApp.openById requires permissions that are not available to simple triggers. You will have to use an installable trigger. Do not rename your function to onEdit otherwise you will be receiving two triggers which is not an easy thing to debug.

simple trigger restrictions

  • Related