1

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?

5
  • Is this a copy of a sheet is was working on previously? Commented Jan 10, 2018 at 13:31
  • Not quite, as it was originally implemented in a bigger Project. But it's basically the same function-call and the same issue. Commented Jan 10, 2018 at 13:48
  • So you have authorized the script in the new document? Commented Jan 10, 2018 at 14:07
  • To be honest, I think I did, but I'm not sure. I've added these oauthScopes Values in the appscript.json: oauthScopes Commented Jan 11, 2018 at 8:34
  • Update: I did authorize the Script but now I'm only getting the Console.log "Google Apps Script: We're sorry, a server error occurred. Please wait a bit and try again" Trying later does not seem to work, as I'm getting this since yesterday :) I do work with a workaround now nonetheless, but I'm still curious why it's not giving me the Mail-Adress anymore. Commented Jan 12, 2018 at 21:27

1 Answer 1

2

[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...

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.