问题
I have a simple script that gets the user email and date/time when a cell is edited on a google sheet. This script works when I run it; however, when a user in my G Suite domain runs the script it returns a blank email. I have searched a bit about this and know that this occurs when triggered by onEdit but was under the impression that it would work if authorized by the script creator when all users are in the same G Suite Domain. Here is an example of the code that I am running:
function onEdit(e) {
var range = e.range;
var userName = Session.getActiveUser().getEmail();
Browser.msgBox(userName);
}
Is there something that I need to do as the G Suite Admin to set up? Can someone help me set the authorization for this to work?
回答1:
In general, a user's email address can not be retrieved on a triggered event. The user must manually click something. If you have a G Suite account, this rule does not apply.
Google Documentation
来源:https://stackoverflow.com/questions/58664414/set-permission-for-getemail-to-work-for-users-on-same-g-suite-domain