Google Apps Script - How To Publish / Install A Container-Bound Script - google-apps-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)

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

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

reuse script or publish a private google sheets script add-on without gsuite or being a business

I'd like to reuse a Google Apps Script between multiple sheets on my personal Google account without publishing the script publicaly. One approach that I'm trying to avoid is to simply copy and paste the script between each sheet that I'm using.
After some reading my impression is that this is typically done by publishing an add-on. I am also under the impression that this can (or could) be done privately, so that no code review is needed and you don't need to pay anything. Most of the related questions I've found on SO seem to have out of date answers (chrome web store instead of GSuite Marketplace) or are too simple (share by publishing an add-on) or refer to gsuite users/admin, etc.
Assuming I need to publish an add-on to get easy sharing across all of my sheets I'm told I need to convert my project to a Google Cloud Project. So I created a Google Cloud Project and then went to transfer my code to that project by going to "Resources - Cloud Platform project" and entering my project number. However, when I do that it tells me that I need to enable oauth for the project and it takes me to a page which looks like it will require formal code review.
I am under the impression that private publishing may be possible if I am an organization. So I went back to the Google Cloud Console and tried to create an organization. Here however, it seems like either I need to be subscribing to GSuite or I need to enable Cloud Identity. The latter seems only pertinent to businesses as during the sign up it asks me for my business name and business domain (e.g. jims-business.com); I stopped when it asked me for my domain.
So again, my question is, is it possible to share a Google script between multiple sheets on my personal account without making a public add-on? After way to much time reading through Google terminology my impression is no, but I'd be happy to be proven wrong!
You don't need to be a G Suite user to publish an add-on, but you do if you want to do it as "internal only", as it requires a valid domain.
I'm afraid you will have to copy the same Script for each file and use an onOpen function.

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!

How to share a Google Spreadsheet that utilizes Google App Scripts within a company domain?

I have a seemingly simple problem that seems to get more complicated the more I get into it.
I have one spreadsheet document.
This spreadsheet utilizes a google apps script, that in turn utilizes various APIs: Domains, Sites, Spreadsheets...
To use this spreadsheet I have to take a few steps -
Authorize the spreadsheets. This dialog only comes up if I use the
script editor, otherwise the Spreadsheet fails silently.
Enable Domain API in Editor -> Resources -> Advanced Google Services
Enable Domain API in Google Developer Console to a seemingly hidden
project that is attached to my spreadsheet. The only way I can access this secret page is through the Advanced Google Services menu in step #2.
After getting through these hurdles, the spreadsheet now functions correctly without having to use the Script Editor.
Now I want to share this spreadsheet with other users in my company's domain.
Is there any easy way to do this, or will every single user I share it to have to jump through these hurdles as well?
Am I thinking about this wrong? The documentation states the script is 'attached' to the spreadsheet. But the more I get into it, the more separate these two things seem to be. I can share a spreadsheet - but the script won't function properly. I can publish a 'web app' with the script editor - but it won't come with the spreadsheet.
Any help appreciated
Frusteratingly yours...
Other users will have to have the same domain permissions as you do.
An approach you could take is have all the permissions related work done on a script that is published as a web app that will take url parameters (to trigger tasks), which is run as you and accessible to others.
From there, your original script can call the published url and send instructions via parameters.
https://developers.google.com/apps-script/guides/content