Publishing Add-ons for Domain-Wide Installation - google-apps-script

I tried to Pre-install a Sheets add-on for all users in the domain.
For that purpose i referred to the steps provided here -> https://developers.google.com/apps-script/add-ons/domain-wide
The add-on was successfully published to all users.
But the users are not able to use the said Add-on in all the sheets.
When trying to run the add-on only the "Help" sub-menu item is visible under the Add-on Menu as shown in image given below.
The above mentioned problem only gets resolved when i follow the below mentioned steps:
Add-ons -> Manage add-ons... -> Click on "Manage" button for the said Add-on -> Select "Use in this document" option as shown in images given below.
The problem gets resolved if and only if the user follows above mentioned steps and then reloads the spreadsheet in the browser.
Also, these steps are needed to be performed again to enable the Add-on for that particular spreadsheet if the user creates a fresh spreadsheet.
This operation is not needed for any Add-on that is available on the Chrome Web store or from the G-Suite Marketplace.
Is there any way in which any Sheets Add-on created using Google Apps Script can be published for domain wide installation and pre-installed in all users accounts and is available to be used in any Spreadsheet without having to Manage that Add-on for use in that particular spreadsheet?
Thanks in advance.

Related

How to automatically load a google apps script menu on all user accounts?

I've searched around for this, but haven't found any info. I've written a few scripts that are bound to certain google docs/sheets. Instead of being bound to a particular doc/sheet, is it possible to have a google action script that loads whenever anyone in my google user account group opens a new or existing doc/sheet?
I know how to load a menu UI. That's simple. I know how to create a stand-alone script. I'm asking for something different. Basically, I want to create a deployment suite of proprietary scripts for our company, and whenever a current or future user of our group opens any new or current Google docs/sheets, the menu appears in their UI.
Is this possible, or do I have to ask my users to "install" my suite every time?
If this exists in GAS, I don't know where to look.
Since you mentioned that you want to have the script available as a "button" that can be accessible by any user from any Sheet or Doc I think the only way to do this is by deploying your script as an add-on then make it available internally through the Google Workspace Marketplace and do a domain installation of this add-on so it gets installed for all your users automatically.
First you would need to create the script and deploy it as an add-on. You can skip the part of the OAuth verification process because you are not publishing a public add-on but just an internal add-on for your organization.
After that make sure to add the Google Workspace Marketplace SDK to your Google Cloud Platform project. In the App configuration section from the Marketplace SDK set everything as internal/private and mark the Google services where you want it to be available and create the store listing.
Once you finish that you will see the app has been approved and an installation link. Make sure to install it domain wide and wait a couple of minutes for it to appear in all your files (from the selected Google services during the configuration) for all your users.
The result should look something like this:
References:
Create and manage deployments
Publish an app

Google App Script: Google sheets addon is not enabled for the new spreadsheet by default

Based on Installed and Enabled states of Editor add-on, I have written code for each states on Google Sheets add-on.
The code is working fine when I test it using the script editor with INSTALLATION CONFIG set to Installed and Enabled. But when I test the published addon after installing, the state always remains disabled for the document.
To enable the add-on, I have to manually go to Add-ons >> Manage add-ons >> Click on the three dots of my installed add-on >> Click on "Use in this document". Please find below screenshot:
Now I need to know whether programmatically it's possible to enable the add-on for the document or not. I tried but couldn't find a way to perform it programmatically.
Any help or suggestions would be helpful.
Edit
I have found that Data connector for Salesforce is already doing this. After clicking "Click to enable the add-on", "Use in this document" gets ticked. So there must be some way to programmatically enable the addon. I have scoured each Google App Script article but I haven't found any piece of code to achieve this.
Thanks.
There's no way to programmatically enable an add-on for a spreadsheet.
As you can see in the reference you shared, enabling an add-on for a document can be done the following ways:
Getting an add-on from the store while using that document, or
Using a previously installed add-on in that document
You have to take into account that an add-on can be enabled for a document, not for a user or for a domain, so having the add-on enabled for all documents by default kind of breaks the idea behind enabling and the related Authorization modes.
Enabling an add-on via onOpen:
If your add-on contains an onOpen trigger that adds an add-on menu with an item with which you can call an add-on function, clicking this item will effectively enable the add-on for your document. See, for example, The complete lifecycle.
File a feature request:
In any case, you can try filing a feature request in this Issue Tracker's component if you think this functionality could be useful.
Reference:
Installed versus enabled

make a script available on ALL google docs via a menu

I have a script on a specific google document that is activated via a menu I've created. I want the menu to appear in ALL google docs files, just like the native menus do (i.e. "File","Edit","View" etc.). How can I achieve this?
Seems like using it as an add-on is the solution. I am not interested in publishing the add-on at this point.
From Google "Publishing add-ons" how-to:
Unpublished
An add-on publication state. Unpublished add-ons (also called developer add-ons) have not completed the publication process and are
not listed in the G Suite Marketplace. This doesn't mean the
add-on is incomplete—it's possible to create and use an add-on without
publishing it. You can even share unpublished add-ons for others to
install and use.
I created an unpublished add-on, but the menu is not there. This is the relevant question:
Can't get menu item to show in an unpublished add-on for google document

Activate an authorized Google Sheets add-on in a new document without "Use in this doc" menu process

I wanted to create an Google Sheets Add-on that opens a sidebar.
In the spreadsheet in which I've coded my Google Script, everything goes well. I published it on the market (for private user) and installed on tester's accounts.
On set-up, everything goes well but when we try to use it on another sheet, the item in my add-on menu doesn't show up. We have to go to Addons -> Manage Addons -> "my addon" -> Use in this doc
We've looked deeper and see that the Auth.Mode didn't authorize my add-on to be used directly when we open/create the spreadsheet.
I would like to know how to, once a user installs the add-on, have every spreadsheet of this user utilize the add-on directly, without the necessity of going through the menus to activate "use in this doc".
Here's an image showing the desired and current behavior:
Google doesn't provide an "Always use this add-on" option - the user has to choose to use your add-on in each spreadsheet that they want to use it. If they don't want to use your add-on, you can't force them to.
Consider this from a security perspective - malicious add-ons would always ask to be used in every user document. The current model ensures that an add-on is only used when wanted, severely hampering malicious data collection / privacy violation.
Instructions for using add-ons and Apps Script
If you're in GSuite, things can be a bit different. I don't have access to a GSuite environment so I can't speak to the particulars, but I would imagine your domain administrator can install add-ons as they see fit. I can see the use case for DAs to also be able to activate their add-ons automatically, to provide tailored services to their organization. Add-ons from the marketplace are still likely to operate with the opt-in-only security model.

Publish an add-on privately

I am trying to publish a test add-on with the option Private, because there is nothing new in this add-on, and would not be accepted by Google if I published it with Public.
The add-on contains a sidebar, a custom menu and a custom function. It works well on its Google Sheet.
In Chrome Web Store, I have added 2 gmails to Edit your tester accounts: under Your developer account. I also created a google group with these 2 gmails.
By following this thread, I did Publish ==> Deploy as Sheets web add-on..., then uploaded different icon and images in Chrome Web Store, paid 5 dollars, left most of boxes blank, then published it with the option Private and chose the created google group.
However, when I open a new Google Sheet with either of these two mails, I cannot find the add-on in Add-ons. By Add-ons ==> Get add-ons..., I cannot find the add-on either.
So does anyone know where this add-on is supposed to appear? Is it because this add-on is under review by Google that it is not available yet.
I am quite surprised to see such a basic publishing is not unclear. Is it because few people publish an add-on with Private?
In your web store dashboard, you should see the link to the add-on. Get the URL for this link and give the URL to the accounts you have created that should have permission. Those accounts need to install the add-on, and then should be able to use it.
I think you can also list your add-on as unlisted and not be required to go through the entire approval process. This makes it a little easier to share your add-ons with specific users.