I have a template spreadsheet which is supposed to execute some code on open.
Part of this code is to open a modal dialog asking the user to wait while the script is running.
I have manually created the onOpen trigger on the template.
Everything works as expected when opening this template spreadsheet.
However when I make a copy of the spreadsheet and open it, the onOpen code executes but the modal dialog is never showing.
The trigger that was manually installed on the first spreadsheet is not added to the copy. If I create the trigger manually on the copy, everything works as expected.
How can I create copies of the initial spreadsheet that show the modal dialog on open without having to create the trigger manually (or do anything else manually) on each copy?
EDIT 1: Here is a simple example.
function onOpen(event) {
var ui = SpreadsheetApp.getUi();
ui.createMenu("Custom menu")
.addItem('Show modal dialog', '_pleaseWait')
.addToUi();
_pleaseWait();
}
function _pleaseWait(){
var htmlOutput = HtmlService
.createHtmlOutput("Processing...")
.setWidth(100)
.setHeight(100);
SpreadsheetApp.getUi().showModalDialog(htmlOutput, 'Hello');
}
Without the onOpen trigger created manually, the menu is added but the modal dialog never shows automatically. However it is displayed by clicking on the added menu item.
Copies of the template spreadsheet will be made and a manual trigger cannot be added on each copy.