我正在构建一个附加组件,需要检查客户还剩下多少个单位。此代码适用于我作为开发人员,但是当用户实际安装应用程序时它不起作用。
// When someone opens the sheet for the first time
function onOpen(e) {
var ui = SpreadsheetApp.getUi()
.createAddonMenu()
.addItem('SMS', 'sms')
.addItem('EMAIL', 'email')
.addItem('SMS and EMAIL', 'emailAndSMS')
.addToUi();
}
// The function for the SMS Side Bar
// It is here I run the code for getting the users email address.
// Nothing is logged to the console at all.
function sms() {
var html = HtmlService.createHtmlOutputFromFile('sms').setTitle('Heartbeat SMS');
SpreadsheetApp.getUi().showSidebar(html);
var userEmail = Session.getActiveUser().getEmail();
Logger.log(userEmail); // Nothing gets logged to the console.
}
我希望看到用户的电子邮件地址被记录,但是我得到一个空字符串