Hi guys im trying to display a sidebar on my google sheets every time it is opened. I am using the onOpen function and calling the html page, but it is not executing. When i run
A simple trigger open function can't open a sidebar because it runs on AuthMode.LIMITED. You should use a function that runs on Auth.Mode.FULL to open a sidebar, like an installable trigger.
I know that this isn't about add-ons but the following quote applies
From https://developers.google.com/apps-script/add-ons/lifecycle#authorization_modes
Note: Add-ons can't open sidebars or dialogs while executing in AuthMode.LIMITED. You can use menu items to open sidebars and dialogs since these run in AuthMode.FULL.
The cannonical references are
See if this works
function showSideBar() {
SpreadsheetApp.getUi()
.showSidebar(HtmlService.createTemplateFromFile('tipA')
.evaluate()
.setTitle('Some title'));
}
and use an installable onOpen trigger on this function. As the previous poster already mentioned, I also don't believe you can show a sidebar (which requires authorization) on a simple onOpen trigger (which doesn't require authorization).
Maybe the user doesn't have permission to edit the SS? Google Developers says onOpen() only fires if the user who is visiting your sheet has permission to edit the SS.
Google has (quite) recently restricted the functionality of onOpen triggers. One of the restrains is the impossibility to show a sidebar. There is no real workaround since installable triggers will only work for the user that created the trigger, not for the other users. Instead you will receive a error notification each time someone opens the document. The best solution I found is to create a button that one can use to open the sidebar, this is easier than a menu and obviously more visible. There is a referenced issue on that subject : https://issuetracker.google.com/issues/69238694