I'm building an add on that needs to check how many units a customer has left. This code works for me as the developer however, it doesn't work when users actually install the application.
// 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.
}
I expected to see users Email addresses being logged, however I get an empty string back