I created a script for Google Spreadsheets, this script just adds a new menu item as described here Custom Menu Items in a Spreadsheet. Then I deploy this script as a Web App and I want all users who install the app to be able to see the new menu item. And I'm stuck at this point.
As I understand, when you deploy a script as a Web App, onOpen functions looses it's meaning. So, inside doGet I create custom trigger for onOpen event, attach myOnOpen handler to it and inside myOnOpen I add a menu item, but the item doesn't show up.
Here's my code:
function doGet() {
var newSheet = SpreadsheetApp.create("new sheet");
var newId = newSheet.getId();
ScriptProperties.setProperty('newId', newId);
ScriptApp.newTrigger("myOnOpen")
.forSpreadsheet(newId)
.onOpen()
.create();
};
function myOnOpen() {
var newId = ScriptProperties.getProperty('newId');
var sheet = SpreadsheetApp.openById(newId);
var entries = [ { name : "Show bingo", functionName : "Bingo" } ];
sheet.addMenu("My Menu", entries);
};
function Bingo() {
Browser.msgBox("Bingo!");
};
So, when a user who installed the app opens "new sheet" spreadsheet, he doesn't see the "My Menu". What am I doing wrong here? Why the menu item doesn't show up? At the end of the day I want to create a Web App which extends Google Spreadsheets UI with additional menus and dialogs.
Any advice is welcome. Thanks!