1

The following line of codes work in ScriptA but not in ScriptB:

var folder = DriveApp.getFolderById(folderId);

The oAuth is the same in both script files' appsscript.json:

...
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets.readonly",
"https://www.googleapis.com/auth/spreadsheets",
"https://www.googleapis.com/auth/drive.readonly",
"https://www.googleapis.com/auth/drive",
"https://www.googleapis.com/auth/script.scriptapp",
"https://www.googleapis.com/auth/script.external_request"
],
...

What am I missing?

TheMaster
  • 45,448
  • 6
  • 62
  • 85
Edmund To
  • 23
  • 7
  • Is the script you are using deployed as an add-on? @EdmundTo – ale13 Oct 06 '20 at 10:17
  • Does this answer your question? https://stackoverflow.com/questions/64079595/i-have-enabled-v8-runtime-but-i-get-an-error-trying-save-were-sorry-a-serve – TheMaster Oct 06 '20 at 14:44
  • 2
    This can be solved by approving `Google Drive API` and `Drive API` in the script file by accessing the menu `Resources` --> `Advanced Google Services...`, and then enable the `Drive API`, and then at the bottom click the link to `Google Cloud Platform API Dashboard` and enable both `Google Drive API` and `Drive API`. As @TheMaster has pointed out, the method of duplicating to a new spreadsheet works but is not ideal if you want to preserve the same FileId https://stackoverflow.com/questions/64079595/i-have-enabled-v8-runtime-but-i-get-an-error-trying-save-were-sorry-a-serve – Edmund To Oct 10 '20 at 06:05
  • @EdmundTo Consider adding it as a answer – TheMaster Oct 10 '20 at 06:20
  • I'm not allowed to add an answer, not sure why. If you can maybe you can add it and I can accept it? @TheMaster – Edmund To Oct 10 '20 at 06:23
  • You may be able to get a answer for why you're not allowed to add a answer by [making a post in the meta](https://meta.stackoverflow.com/questions/ask). I'm not comfortable with adding your comment as my solution. If the meta fails, I might still be able to post a community wiki post(sort of a public user post). If all that is too much, You may leave it as is. – TheMaster Oct 10 '20 at 06:34

2 Answers2

3

This can be solved by activating the Google Drive API Advanced Services in the script file by accessing the menu Resources > Advanced Google Services..., and then enable the Drive API, and then at the bottom click the link to Google Cloud Platform API Dashboard and enable the Drive API there as well.

ale13
  • 5,679
  • 3
  • 10
  • 25
1

I encountered a similar issue (though with the DriveApp.getFiles() and DriveApp.searchFiles() functions), I was seeing the "Something Went Wrong - Please reload the page to try again" error. After over an hour investigating I've narrowed it down to the Google Cloud Project (GCP) that the problematic AppScript is associated with.

If you've selected a GCP project for the script, then that project must have the appropriate GCP API enabled. For the DriveApp SDK/library I had to enable the Google Drive API (see docs), which then fixed the issue for me.

If the script is still using the default project I found that no additional action was needed; it probably means the underlying GCP project already has all the needed APIs enabled for each supported AppScript integration.

Interestingly, this is mentioned under Advanced services requirements, but it's not clear why DriveApp functions are also affected, as they aren't listed under "advanced services" (we're not using Drive API after all). I created a bug ticket in google's issue tracker to try and get to the bottom of this one.

tutuDajuju
  • 10,307
  • 6
  • 65
  • 88