Session.getActiveUser().getEmail()不返回任何值 [英] Session.getActiveUser().getEmail() returns no Value

查看:68
本文介绍了Session.getActiveUser().getEmail()不返回任何值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的第一个Stackoverflow问题,所以我在这里尽力使自己变得清晰和结构化,但是请您原谅我的初衷错误:)

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 :)

因此,我在使用Google的脚本编辑器时遇到了一些问题,基本上是在调用 Session.getActiveUser().getEmail() Session.getEffectiveUser ().getEmail()函数,但没有一个返回值.

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?

感谢和问候!

推荐答案

[如果您在这里发现自己],请参见文档:

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

...例如,用户的电子邮件地址在任何情况下均不可用 允许脚本在未经用户授权的情况下运行的上下文, 就像一个简单的onOpen(e)或onEdit(e)触发器...

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

这说明了OP面临的行为...

This explains the behaviour the OP was facing...

这篇关于Session.getActiveUser().getEmail()不返回任何值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆