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?
Use the SuccessHandler()
of the call to gsSheetCreateSuccess()
to close the sidebar.
google.script.run
.withSuccessHandler(google.script.host.close)
.gsSheetCreateSuccess();
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.