Google Spreadsheets:无法通过Session.getActiveUser().getEmail()获取用户电子邮件 [英] Google Spreadsheets: Can't Fetch User Email via Session.getActiveUser().getEmail()

查看:45
本文介绍了Google Spreadsheets:无法通过Session.getActiveUser().getEmail()获取用户电子邮件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,我有一个电子表格,该电子表格应该会自动获取每个用户的电子邮件并为他们的电子邮件分配自定义用户名.我使用此数据在工作表上显示每行最后由---编辑"的行.这也使我可以列出所有查看电子表格的用户,并在他们最后一次打开电子表格时进行记录.

So I have a spreadsheet that is supposed to automatically fetch every users' emails and assign custom usernames for their emails. I use this data to display a per-row "last edited by ---" on a sheet. This also allows me to list all the users viewing the spreadsheet and log when they last opened it.

但是,Session.getActiveUser().getEmail()返回除我以外的任何人的空白字符串.

However, the Session.getActiveUser().getEmail() returns a blank string for anyone else other than me.

我已经看到您可以做到这一点,以使脚本在用户的帐户下运行.但这仅适用于已部署的Web应用程序.我需要将其集成到电子表格中.关于我该怎么做的任何想法?

I've seen that you could make it so that the scripts run under the user's account. But that is only for deployed web apps. I need to integrate it to spreadsheets. Any ideas on how I should do that?

推荐答案

您应该首先在脚本编辑器中运行onEdit函数并对其进行授权,然后它应该显示当前用户.

you should first run your onEdit function in the Script Editor and authorize it, then it should show the current user.

这篇关于Google Spreadsheets:无法通过Session.getActiveUser().getEmail()获取用户电子邮件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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