Bruce McGivern
Bruce McGivern

Reputation: 36

Session.getActiveUser().getEmail() returns no Value

this is my first Stackoverflow Questions, so I'm trying to do my best to be clear and structured here but please forgive me for beginner mistakes :)

So I'm having a little issue with the Script Editor of Google, basically I'm calling the Session.getActiveUser().getEmail() as well as the Session.getEffectiveUser().getEmail() Function yet none of them is returning a value.

Here's the full Code I'm using:

function onEdit(e){
    var email = Session.getActiveUser().getEmail();
    var range = e.range;
    range.setNote('Last modified: ' + new Date() + "User is " + Session.getEffectiveUser().getEmail() + "; " + Session.getActiveUser().getEmail());
}

Yet the Output I'm getting is always the same: Output in the Sheet

The weird thing is, that this occured a few days ago, before that the same functions worked fine.

Has someone ever experienced something like this? Is there a workaround to get the Mail-Adress or the User-Name in the Script-Editor?

Upvotes: 1

Views: 1499

Answers (1)

user9937931
user9937931

Reputation:

[In case you find yourself here] From the documentation:

...for example, the user's email address is not available in any context that allows a script to run without that user's authorization, like a simple onOpen(e) or onEdit(e) trigger...

This explains the behaviour the OP was facing...

Upvotes: 2

Related Questions