This accepted answer says that it's not possible to get custom Google Sheets functions into Google Sheets from a Google Workspace Add-on.
However, I came across a counterexample that proves the above conclusion incorrect.
The link to the workspace add-on is here.
One can install the add-on as expected like this.
But immediately upon installing the Workspace Add-on, one can access the dropdown menu under the extensions tab (usually reserved for Editor Add-ons only) without taking any additional steps. The dropdown menu is immediately available. All one needs to do is click the button once to install the custom functions.
So, somehow, installing the Workspace Add-on automatically installs the Editor Add-on.
How is this accomplished?
I assume the following code is also applicable in this case too.
Code.js
const ss = SpreadsheetApp.getActiveSpreadsheet();
function onOpen( e ) {
ui.createAddonMenu()
.addItem( 'Start', 'showSidebar', )
.addToUi();
const menuItems = [];
menuItems.push({ name: 'Start' , functionName: 'showSidebar' });
ss.addMenu( 'MyApp', menuItems, );
}
function showSidebar() {
// code TBD
// right now, I'm just trying to get the menu to appear
}
Sidebar.html
<html>
<body>
<div>Hello World</div>
</body>
</html>
appsscript.json
{
"timeZone":"America/Los_Angeles",
"dependencies":{
},
"exceptionLogging":"STACKDRIVER",
"runtimeVersion":"V8",
"addOns":{
"calendar":{
"createSettingsUrlFunction":"getConferenceSettingsPageUrl",
"conferenceSolution":[
{
"id":"my-video-conf",
"logoUrl":"https://lh3.googleusercontent.com/...",
"name":"My Video Conference",
"onCreateFunction":"onCreateMyVideoConference"
},
{
"id":"my-streamed-conf",
"logoUrl":"https://lh3.googleusercontent.com/...",
"name":"My Streamed Conference",
"onCreateFunction":"onCreateMyStreamedConference"
}
],
"currentEventAccess":"READ_WRITE",
"eventOpenTrigger":{
"runFunction":"onCalendarEventOpen"
},
"eventUpdateTrigger":{
"runFunction":"onCalendarEventUpdate"
},
"eventAttachmentTrigger":{
"label":"My Event Attachment",
"runFunction":"onCalendarEventAddAttachment"
},
"homepageTrigger":{
"runFunction":"onCalendarHomePageOpen",
"enabled":true
}
},
"common":{
"homepageTrigger":{
"runFunction":"onDefaultHomePageOpen",
"enabled":true
},
"layoutProperties":{
"primaryColor":"#ff392b",
"secondaryColor":"#d68617"
},
"logoUrl":"https://ssl.gstatic.com/docs/script/images/logo/script-64.png",
"name":"Demo Google Workspace Add-on",
"openLinkUrlPrefixes":[
"https://mail.google.com/",
"https://script.google.com/a/google.com/d/",
"https://drive.google.com/a/google.com/file/d/",
"https://en.wikipedia.org/wiki/",
"https://www.example.com/"
],
"universalActions":[
{
"label":"Open settings",
"runFunction":"getSettingsCard"
},
{
"label":"Open Help URL",
"openLink":"https://www.example.com/help"
}
],
"useLocaleFromApp":true
},
"drive":{
"homepageTrigger":{
"runFunction":"onDriveHomePageOpen",
"enabled":true
},
"onItemsSelectedTrigger":{
"runFunction":"onDriveItemsSelected"
}
},
"gmail":{
"composeTrigger":{
"selectActions":[
{
"text":"Add images to email",
"runFunction":"getInsertImageComposeCards"
}
],
"draftAccess":"METADATA"
},
"contextualTriggers":[
{
"unconditional":{
},
"onTriggerFunction":"onGmailMessageOpen"
}
]
},
"docs":{
"homepageTrigger":{
"runFunction":"onEditorsHomepage"
},
"onFileScopeGrantedTrigger":{
"runFunction":"onFileScopeGrantedEditors"
}
},
"sheets":{
"homepageTrigger":{
"runFunction":"onOpen"
},
"onFileScopeGrantedTrigger":{
"runFunction":"onFileScopeGrantedEditors"
}
},
"slides":{
"homepageTrigger":{
"runFunction":"onEditorsHomepage"
},
"onFileScopeGrantedTrigger":{
"runFunction":"onFileScopeGrantedEditors"
}
}
}
}