I'm working on a Sheets Add-on and chose the* Google Sheets Add-on Script * as
a starting point rather than creating a blank project. The canned script
included in the template has sample code for opening a dialog and sidebar
from the add-on menu of the associated spreadsheet. The script adds the
sub-menus,: 'Show dialog' and 'Show sidebar'. However, when I select
either of those menu items the script errors out before full execution with
the following error showing in the Java Console:
*Uncaught Error: SES not supported, aborting taming frame initialization.*
After much hair pulling and research, I learned that adding the following
line to the script will fix the problem:
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
Here are the codes for the two affected functions created by default when
the user creates a script using the * Google Sheets Add-on Script *template:
function showSidebar() {
var ui = HtmlService.createTemplateFromFile('Sidebar')
.evaluate()
.setTitle(SIDEBAR_TITLE);
SpreadsheetApp.getUi().showSidebar(ui);
}
function showDialog() {
var ui = HtmlService.createTemplateFromFile('Dialog')
.evaluate()
.setWidth(400)
.setHeight(190);
SpreadsheetApp.getUi().showModalDialog(ui, DIALOG_TITLE);
}
The following are the above functions modified to add SandboxMode:
function showSidebar() {
var ui = HtmlService.createTemplateFromFile('Sidebar')
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setTitle(SIDEBAR_TITLE);
SpreadsheetApp.getUi().showSidebar(ui);
}
function showDialog() {
var ui = HtmlService.createTemplateFromFile('Dialog')
.evaluate()
.setSandboxMode(HtmlService.SandboxMode.IFRAME)
.setWidth(400)
.setHeight(190);
SpreadsheetApp.getUi().showModalDialog(ui, DIALOG_TITLE);
}
Executing the codes as modified work flawlessly.
My reason for posting this is twofold:
1. Persuade Google to update its templates to correct coding that no
longer works, specifically the Google Sheets Add-on Script template in this
example, nut there may be others.
2. Provide help for users experiencing similar issues. Other postings to
the google forums relating to the Java Console error are confusing and
provides no insight how to fix this particular problem
--
---
You received this message because you are subscribed to the Google Groups
"Google Caja Discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.