title: Can a Google Spreadsheet Apps Script library contain a user dialog?
body: <p>Are there restrictions on what may be in an Apps Script library to be used by Google Spreadsheets?  Specifically, can a library include an HTML dialog?</p>
  <p>I've created a spreadsheet script that adds a menu item to present the user with a dialog box.  It uses
  <code>HtmlService.createHtmlOutputFromFile('mappingForm').setSandboxMode(HtmlService.SandboxMode.IFRAME)</code></p>
  <p>as described in <a href="https://developers.google.com/apps-script/guides/html/communication" rel="nofollow noreferrer">https://developers.google.com/apps-script/guides/html/communication</a>.  The HTML file includes HTML, CSS and JavaScript with jQuery.  It uses <code>google.script.run</code> to populate the dialog with data from the spreadsheet and to submit a form to it.</p>
  <p>This all works fine in the original spreadsheet.</p>
  <p>I need multiple spreadsheets to use this same code, however, so I'm trying to follow the general idea of <a href="https://stackoverflow.com/questions/14473368/google-spreadsheet-scripts-shared-across-spreadsheets-not-libraries">Google Spreadsheet Scripts shared across spreadsheets (not libraries)</a> to have a master script with a spreadsheet template and multiple copies.</p>
  <p>I followed the directions at <a href="https://developers.google.com/apps-script/guide_libraries" rel="nofollow noreferrer">https://developers.google.com/apps-script/guide_libraries</a> to create a library from the original spreadsheet.  When another spreadsheet uses the library, I'm able to get the dialog to appear, but all calls back to the server (either to populate the dialog or to submit a form) fail with an error caught browser-side by the <code>google.script.run.withFailureHandler</code> as an <code>Error</code> object with properties:</p>
  <pre><code>message: &quot;We're sorry, a server error occurred. Please wait a bit and try again.&quot;
  name: &quot;ScriptError&quot;
  </code></pre>
  <p>I've placed Logger calls in the apps script to see if the server-side functions are being called but none of them are being hit.  The script editor's Execution Transcript shows:</p>
  <blockquote>
  <p>[14-12-27 19:38:05:340 PST] Starting execution</p>
  <p>[14-12-27 19:38:05:372 PST] Execution failed: We're sorry, a server error occurred. Please wait a bit and try again. [0.0 seconds total runtime]</p>
  </blockquote>
  <p>The client is making the call, but something is failing before it reaches the spreadsheet script.</p>
  <p>This makes me wonder whether</p>
  <ol>
  <li>I need to do something differently for the code to work as a library.</li>
  <li>Libraries can't have dialogs.</li>
  <li>There's a server bug.</li>
  </ol>
  <p>Thanks in advance for any suggestions.</p>