Reputation: 11
I am attempting to call Session.getActiveUser
in order to auto-fill certain fields in a Google Sheets document when other fields are edited. All users are in the same domain; however, I receive an error message, "You do not have permission to call getActiveUser."
I was under the impression from existing documentation that users within the same domain can access one another's information through custom scripts - is this incorrect? If so, I know that there are several workarounds, but if not, is there something else I could be doing wrong?
Thanks in advance!
Upvotes: 1
Views: 3365
Reputation: 5243
The link in KRR's answer contains the information you need. Here's the excerpt answering you question:
Session.getActiveUser()
without user authorization, even for users within the same domain:If your custom function throws the error message
You do not have permission to call X service.
, the service requires user authorization and thus cannot be used in a custom function.
Session.getActiveUser()
in custom functions (directly in cells). You need to create a custom menu instead:To use a service other than those listed above, create a custom menu that runs an Apps Script function instead of writing a custom function. A function that is triggered from a menu will ask the user for authorization if necessary and can consequently use all Apps Script services.
Upvotes: 1
Reputation: 4917
"user3889423" is correct, you need Authorization of the user, in order to call the getActiveUser().
You can find this information in this link below: https://developers.google.com/apps-script/guides/sheets/functions#advanced
Upvotes: 1
Reputation: 27242
If that script runs without the explicit authorization of the user, you won't be able to get the ActiveUser (I think). It should work though when a user authorizes the script first.
Upvotes: 0