DriveApp.getFolderById results in an error

I am having problems with the getFolderById function. I am the owner of the folder in question. The specific call is as follows.

var folder = DriveApp.getFolderById('string_id_of_my_folder'); 

I am passing a long string of folder id inside the function. I ran the function inside the editor to make sure that permissions are enabled and I am not getting any errors.

But when I try to run the function inside the spreadsheet, I get the following error message: "You do not have permission to call getFolderById."

What am I doing wrong?

+5
source share
1 answer

The problem is that user functions and simple triggers work with limited rights: you cannot perform actions that require user credentials, for example, reading from another file. These restrictions are described here for custom functions and here for simple triggers .

Installed triggers do not have this limitation. Therefore, if you need to access another when opening the current file or from a stand-alone script, you need to set the Open trigger. Here is the google documentation .

0
source

Source: https://habr.com/ru/post/1241566/


All Articles