This question already has an answer here:
- How to hide the Sidebar in a Google Spreadsheet using a script? 2 answers
I have a dialog I'm displaying via the html service in Google Apps Script. From the dialog, I call a google script function (openFormSidebar
) that opens a sidebar with a success handler to close the dialog.
HTML in Dialog
<button
onclick="google.script.run.withSuccessHandler(google.script.host.close()).openFormSidebar()">
Create Form</button>
The problem is that the dialog is closing (the success handler is running) before the sidebar is opened.
gs code
function openFormSidebar () {
var html = HtmlService.createHtmlOutputFromFile('FormSidebar')
.setTitle('Form Creation')
.setWidth(300)
.setSandboxMode(HtmlService.SandboxMode.IFRAME);
SpreadsheetApp.getUi() // Or DocumentApp or FormApp.
.showSidebar(html);
}
Even if I make the openFormSidebar
function a simple logger statement (i.e. Logger.log('test')
) it doesn't execute (nothing is logged).
What am I missing? Why is this occuring?