As user Serge insas answered here,
Ui Dialogs can not be called by time triggered functions, they have to be triggered by a user action, that's to say a click on a menu item or some sort of button that calls the function showing the UI.
What about calling showSidebar() or showModalDialog() from a cell? Something like the following formula, which should open the sidebar automatically when the value in A1 is greater than 0:
=if(A1>0;showSidebar();"nothing to show")
Is this possible?
This is my script:
function onOpen() {
SpreadsheetApp.getUi().createAddonMenu().addItem('Open Beeper', 'openBig').addToUi();
}
function openBig() {
var htmlContent = HtmlService.createHtmlOutputFromFile('audioHtml').setTitle('Beeper');
SpreadsheetApp.getUi().showSidebar(htmlContent);
}
I can open the sidebar by clicking the item in the addons menu without problems but when I call openBig() from a cell I get the following error:
Cannot call SpreadsheetApp.getUi() from this context.
What am I doing wrong? What is missing?