title: Unable to open modal dialog in onOpen function of a spreadsheet copy using Apps Script
body: <p>I have a template spreadsheet which is supposed to execute some code on open.<br>
  Part of this code is to open a modal dialog asking the user to wait while the script is running.<br>
  I have manually created the onOpen trigger on the template.<br>
  Everything works as expected when opening this template spreadsheet.</p>
  
  <p>However when I make a copy of the spreadsheet and open it, the onOpen code executes but the modal dialog is never showing.<br>
  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.</p>
  
  <p><strong>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?</strong></p>
  
  <hr>
  
  <p><strong>EDIT 1:</strong> Here is a simple example.</p>
  
  <pre><code>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');
  }
  </code></pre>
  
  <p>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.<br>
  Copies of the template spreadsheet will be made and a manual trigger cannot be added on each copy.</p>