1

I have a Google Apps Script function, push_permissions(), that reads permissions from a Spreadsheet and applies them to Google Drive files and folders. The function works as expected when manually run, but I wanted to automatically trigger this function every time edits are made on a certain range. So I made this onEdit() function:

function onEdit(e) {
  if (e.range.columnStart == 10 && e.range.rowStart > 2 && e.value.includes('@gmail.com')) push_permissions();
};

Whenever onEdit() is triggered, it throws this error:

Exception: You do not have permission to call SpreadsheetApp.openByUrl. Required permissions: https://www.googleapis.com/auth/spreadsheets
at onEdit(Permissions:2:27)

Any way to make this work?

Majal
  • 1,635
  • 20
  • 31
  • Yes the scope was added since the function works on its own. push_permissions starts with this: `let ss = SpreadsheetApp.openByUrl('https://docs.google.com/spreadsheets/d/xxxx-ID-xxxx/');` And yes, V8 enabled. – Majal Feb 27 '20 at 03:22
  • Sorry, I'm new in GAS. Can you please point me out on how I would do that? Thank you! – Majal Feb 27 '20 at 03:24
  • Do what? "Try putting that scope in your manifest file." Thanks. I tried the installable trigger but it threw the same error. I followed this: https://stackoverflow.com/a/49063346/2756066 – Majal Feb 27 '20 at 03:27
  • Take a look at this:https://developers.google.com/apps-script/concepts/scopes – Cooper Feb 27 '20 at 03:28
  • Let us [continue this discussion in chat](https://chat.stackoverflow.com/rooms/208611/discussion-between-cooper-and-majal). – Cooper Feb 27 '20 at 03:29

1 Answers1

4

onEdit has the simple type of Google Apps Script Triggers.

For getting full access of scopes you have to install the trigger for EDIT event.

Please check Managing triggers manually for that.

contributorpw
  • 4,739
  • 5
  • 27
  • 50