0

So I wrote a few custom functions for a spreadsheet I've been working on to streamline the process of entering and updating data. All the functions work perfectly fine in their current state, but I then wanted to set up some triggers such that the functions refresh on every edit. Because of this, I had to change some of my code from SpreadsheetApp.getActiveSpreadsheet() to something like SpreadsheetApp.openById(spreadsheetidhere), as trying to retrieve the active spreadsheet doesn't seem to work with on edit triggers. This gave me the following error:

Exception: You do not have permission to call SpreadsheetApp.openById. Required permissions: https://www.googleapis.com/auth/spreadsheets (line 80).

I then added the proper permissions to the appscript.json manifest file - it currently has "oauthScopes": ["https://www.googleapis.com/auth/userinfo.email", "https://www.googleapis.com/auth/spreadsheets"]. These permissions have clearly been applied to my project file, as I was prompted to provide authorization and it is also clearly displayed on the Overview page. Despite this, I am still receiving the exact same error every time, as if I never granted the permissions at all.

If anyone can tell me a workaround or fix, or even just a way to make the triggers work with SpreadsheetApp.getActiveSpreadsheet(), that would be greatly appreciated!

invy
  • 1
  • Have you read the restrictions for custom functions? Also onEdit() functions run on simple triggers and don't do somethings that require permissions. It might be worth you time to read the documentation. – Cooper Jan 06 '22 at 20:40
  • 1
    Does this answer your question? [You do not have permission to call openById](https://stackoverflow.com/questions/30587331/you-do-not-have-permission-to-call-openbyid) – Kos Jan 06 '22 at 21:23
  • @Cooper I've read through most of the relevant information, and I've been using the installable onEdit trigger rather than the simple one, although idk if that really changes anything. I've tried quite a few solutions I've seen on stack overflow already to no avail, so I'm kinda just stuck for now. – invy Jan 07 '22 at 19:33
  • @Kos I tried all of the relevant solutions from that thread already, I never had `@OnlyCurrentDoc` in my code to begin with or anything, and the explicit scope solution appears to do nothing for me. – invy Jan 07 '22 at 19:35
  • @invy if you think your case is unique, prepare minimal reproducable example (AKA steps to reproduce the issue) post it here, or at http://issuetracker.google.com/ if you think it's an Apps Script bug – Kos Jan 07 '22 at 19:47

0 Answers0