How to link an add-ons to a google sheet? - google-apps-script

I have read some documentation about the notion of "installed or enabled editor add-ons" but I didn't understand very well. I have developped an add-ons that work with a specific google sheet template. The rule is that I will make some copy of the sheet model and distribut them to collaborator or they will do themselves the copy of the model and work on it.
I would like to know if it's possible to link the add-ons to the doc and in that way my collaborator don't need to search the add-on on G-suite store because ideally the copy of my google sheet template will offer the possibility to install the linked addon directly in the menu of the google sheet.
Finally from what i understood here,https://developers.google.com/gsuite/add-ons/concepts/editor-auth-lifecycle
Authorization model
Two properties of editor add-ons make them especially easy to share and use:
Once you get an editor add-on from the store, you see it in the Add-ons menu for every
you open or create. Collaborators on those documents won't see the add-on except in documents
where you actually use it.
Once you use an editor add-on in a document, your collaborators also see it in the Add-ons menu,
but just for that document (unless they have also installed that add-on).
I would like to have the second exemple and not the first.
Thank you for your answers guys

Related

How can I "publish" an editor add-on to be used by just me?

I'm involved in a standards development group where the meeting invitations are sent out, not as calendar invites, but as Word docs. I've written a script that allows me to take the Word doc uploaded to Google Drive, and run the script to create an entry on a Google calendar that I maintain.
At the moment, the script is unpublished, and to run it on the docs I use the "Test as Add-On" function from the script editor. That's a bit cumbersome because I have to go through the selection dialog to select the doc I want to run it on. Additionally, in the new scripts editor, it won't be possible to delete old tests and so my test dialog will end up getting filled up with every run of the script I've ever carried out.
It would be much better if I could have the script available to me, and me only, from the Extensions->Add-Ons menu when I open a doc. The script is not suitable for general publication: it works only on docs with the exact format of these meeting notices, so it should only be run by someone who knows what they're doing, and it accesses a calendar that I own, so I don't want to make it public. But I would like to be able to put it into some kind of "deployed" state so that, as I say, when I open any doc when I'm logged in as me, the script is just available directly from the Add-Ons menu.
Is there any way to achieve this? Or is there an alternative approach possible to this general problem, of having a script that you want to run on multiple documents that you own without having to formally publish it?
One option to "test as add-on" without publishing the script as an editor add-on, is to use installable triggers instead of simple triggers. This triggers should be created by using code in order to avoid having to add any code to each spreadsheet.
If you are determined to take the publishing path you can set your add-on listing to be "unlisted", this means that the add-on will not appear on the Google Workspace Marketplace, people will need to know the installation URL to be able to install the add-on.
Other options:
If you have a Google Workspace account you could publish the add-on privately for your domain. If you don't have this account type or if this is "not good enough", you might make your Google Apps Script add-on publicly installable but limit its core features to be used only by you by making use of a dynamic custom menu. For details please checkout Editor add-on authorization
The dynamic custom menu might based on a setting depending on the user email address. To make this work, as the Session.getActiveUser() requires authorization to run, it can't be executed by simple triggers, but you might implement a workflow to save it or a flag, i.e. add an option to the custom menu to initialize the editor add-on.
Another option is to make the dynamic custom menu based on the spreadsheet structure and/or content.
References
Installable Triggers
Enable and configure the Google Workspace Marketplace SDK
Related
Google Apps Script: Dynamically creating spreadsheet menu items
Publish an add-on privately

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.

Deploying my custom Google Sheet

I have been searching for an answer, more that likely using the wrong terminology, to my question and I have read through the Google documentation but I am now more confused than when I started looking for the answer.
I'm new to Google Apps and a complete beginner at Javascript. I recently started working in a Google Apps school (we have our own domain) and I have started developing some custom Google Sheets to aid other teachers and boost productivity.
I have developed a Sheet with some custom scripts and a custom menu bar to call the various functions of the script. Since I am so new to Javascript my scripts have some bugs that I fix as other users report them to me. However, my problem is that when I fix a bug in my "master" Sheet the end user must open the shared master Sheet and make a copy of it to benefit from the update. I want to update to be pushed out to all copies of the sheet (circa 4 copies)
I know need to deploy it but I don't know whether I need to deploy it as a web app or a sheets add-on from the script editor? Again, we have our own domain so I do believe I don't need to have it approved by Google to use it internally in our domain?
Based from this documentation, public add-ons require a review before publication, since you have your own domain, you can publish just for users within your domain without a review.
To publish an add-on for the first time, follow these steps. If you also want to let Google Apps domain administrators install and authorize your add-on for all users in their domain, follow the steps for domain-wide publication as well.
When you fixed your bugs and wanted it to be updated to all copies of sheets, you can follow this Update your add-on link to update an add-on that you have already published.
Open the add-on project in the script editor.
Make the necessary changes to your code, then save a new version of your project by clicking File > Manage versions, then Save
New Version. Close the Manage Versions dialog.
Click Publish > Deploy as add-on. (Or Sheets or Docs or Forms add-on.)
In the dialog that appears, change the add-on's details as needed, select the new version of your script, then click Update store
item. (If you change the add-on's name, make sure you also change
the name of the Apps Script project to match, as the project name is
shown in the authorization dialog.)
In the store listing, click Publish changes, then click OK in the dialog that appears.
Hope this helps!

Install add-ons on every document in a folder

I have made an add-ons for Google app scripts . Now I want to add it in every document in one folder. How can i do that?
In this tutorial https://developers.google.com/apps-script/quickstart/docs, it only uses for one document.
If your add-on was published to Google Marketplace/Chrome Web Store and you installed it from there, and you are the owner of all the docs in the folder, that add-on should be available in your docs under Add-ons menu. I think it's the same for domain-specific add-ons as well (have no way to check it at the moment).
If you just created an add-on in a doc-bound script, then the add-on will only be available in that doc. To add it to other docs, you will have to copy your script into those docs manually - there is no API way to do it.

Google Apps Script - How To Publish / Install A Container-Bound Script

I have a document container-bound script, that I would like to publish, I would like to make it available to people in my google apps organization. I know the script gallery is only available to spreadsheet apps, so how do I publish it. Or, more specifically, currently the script is bound to one document, how do I make it run on all documents? My user base is fairly small, about 300 people, and I can have each one of them install it if need be.
Thanks,
Ari
There are limited options for distributing container bound scripts. When a document with a container bound script is copied, the script is also copied. So if the 300 people in your organisation copied the document they would also have a copy of that script. The issues with this techniques is that the script is only attached to that particular document and creating a new document, rather than taking another copy of the template, or opening an existing document will not include your script functionality. The other issue the script in the copies of your template becomes orphaned and you cannot push updated versions. Using Managed Libraries addresses this to a degree but the end user still needs to select the newer version of the script in the script editor.
A way to mass deploy your script in your organisation is using Google Apps Script authored Add-ons. Add-ons are installed by users and become available to every document they work on. The script behind add-ons can also easily be upgraded without any user intervention. One issue with this approach is all add-on's need to be approved by Google. This introduces a risk that Google will not publish your script as an add-on. Whilst there is a public store of add-ons after your project is approved by Google there are visibility options to restrict access and prevent there general visibility. As per add-on publication step #12:
In the "Visibility options" section, select which users will be able
to find your add-on — usually either all users or only users with an
account in your Google Apps domain.
Hopefully when add-ons leave developer preview Google Apps domains will have more control over publication and visibility (I've opened a feature request for this)