I'm new to google app script. I have configured my add-on. I cannot open the add-on once the user has already opened it.
Suppose i have opened the add-on. Now I'm again going to open it then it shows the "content not available for this message". I have attached the image.
My code is below:
appscript.json
{
"timeZone": "America/New_York",
"exceptionLogging": "STACKDRIVER",
"runtimeVersion": "V8",
"oauthScopes": [
"https://www.googleapis.com/auth/spreadsheets.readonly",
"https://www.googleapis.com/auth/userinfo.email",
"https://www.googleapis.com/auth/script.container.ui",
"https://www.googleapis.com/auth/script.external_request",
"https://www.googleapis.com/auth/spreadsheets"
],
"addOns": {
"common": {
"name": "Test Addon",
"logoUrl": "https://test/add-on_logo-32x32.png",
"layoutProperties": {
"primaryColor": "#2772ed"
},
"homepageTrigger": {
"runFunction": "showSidebar"
}
},
"sheets": {
"homepageTrigger": {
"runFunction": "showSidebar"
}
}
},
}
Macro.gs
function onOpen() {
SpreadsheetApp.getUi()
.createMenu('Custom Menu')
.addItem('Show sidebar', 'showSidebar')
.addToUi();
}
function doGet() {
return HtmlService.createHtmlOutputFromFile('home');
}
function include(filename) {
return HtmlService.createHtmlOutputFromFile(filename)
.getContent();
}
function showSidebar() {
var html = HtmlService.createTemplateFromFile('login').evaluate().setTitle("test Add-on")
SpreadsheetApp.getUi()
.showSidebar(html);
}
function goToHome(token) {
const scriptProperties = PropertiesService.getScriptProperties();
scriptProperties.setProperty('API_TOKEN', token);
var html = HtmlService.createTemplateFromFile('home').evaluate().setTitle("test Add-on")
SpreadsheetApp.getUi()
.showSidebar(html);
}
Can anyone tell me when I have made a mistake?
I believe the
addOnskey in the manifest (appscript.json), and the associated trigger functions only work with the CardService based UI.I have built a similar application with a smaller appscript.json (for Slides):
and the (slightly redacted)
Code.gscontents:This works fine to open from the menu in Google Slides, but before going this route I also spent a lot of time attempting to use the triggerFunctions and the
addOnskey in the manifest.