Reputation: 663
I'm developing a Google Sheets Add-on and I'm trying to have the script both close a HTML sidebar and open a dialog.
This code below doesn't work because the dialog is opened and then closed.
HTML file
google.script.run.gsSheetCreateSuccess();
google.script.host.close();
.gs file
function gsSheetCreateSuccess() {
var ui = SpreadsheetApp.getUi()
ui.alert(
'Setup Complete',
"Success! You've Successfully completed setup on this spreadsheet.",
ui.ButtonSet.OK)
}
And this code below (the reverse) doesn't work because the HTML file (the sidebar) is closed before it can execute google.script.run.gsSheetCreateSuccess();
and open the dialog.
HTML file
google.script.host.close();
google.script.run.gsSheetCreateSuccess();
How can I simultaneously close the sidebar and open a dialog?
Upvotes: 3
Views: 2509
Reputation: 45750
Use the SuccessHandler()
of the call to gsSheetCreateSuccess()
to close the sidebar.
google.script.run
.withSuccessHandler(google.script.host.close)
.gsSheetCreateSuccess();
Upvotes: 7