简体   繁体   中英

Set Permission for getEmail to Work for Users on Same G Suite Domain

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?

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM