0

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?

Jim
  • 1
  • 2
  • Hello @Jim, Have you tried making this an [installable trigger](https://developers.google.com/apps-script/guides/triggers/installable), rather than a simple one? Do you obtain the same results? Cheers – carlesgg97 Nov 04 '19 at 14:48
  • Hey @Jim were you able to fix the issue? – carlesgg97 Nov 07 '19 at 12:29

1 Answers1

0

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

  • I do have a G Suite account but still cannot retrieve the user's email address when and edit occurs. Any idea if I as the admin need to do something to get this to work for all accounts on this domain? – Jim Nov 02 '19 at 01:31
  • There is a good chance the script owner has to have admin access. I've never tried it as a regular user. – Efficient Small Business Nov 07 '19 at 19:29