The "library solution" is actually your best bet. It is not as complicated as it sounds, but it takes a little bit of one-time work.
First you create your script in one spreadsheet (let's call it the Master spreadsheet).
Save a version of the script by clicking File → Manage versions in the script editor, and give your version a name:
![Screenshot of the Manage Versions dialog](https://i.stack.imgur.com/8OK3g.png)
Close this dialog, and go to File → Project Properties. Here, find the Project key, which is a seamingly random combination of characters:
![Screenshot of the Project Proerties dialog](https://i.stack.imgur.com/ljYD5.png)
Copy or take note of the project key.
When you have created a new spreadsheet and want to reuse the script, go to the script editor and click Resources → Libraries (if you haven't saved your new script, you will be asked to so now).
In the Find a Library field, paste the project key from the Master project (1) and click Select (2):
![Screenshot of the Manage Libraries dialog](https://i.stack.imgur.com/4528O.png)
This will populate the list with your Master script. Give it a more friendly name (3), and turn on Development Mode (4) (this will allow you to debug the library). Select the most recent version of your script (5).
Now you're able to use functions from your included library in your new script. Just prepend any function names with the name you specified in (3), so that if you identified your library as MyLibrary
, and your library has a function myFunction
that you want to call, you call MyLibrary.myFunction()
.
When you want to update your library, you simply do so, and save the file. Any scripts that depend on the library will see the updated library code.
I just tried this excercise as a proof-of-concept:
- Set up a library with a function:
function myFunction() {return "Foo"}
- Include it in another script, identifying the library as
MyLibrary
- Called the library function with
Logger.log(MyLibrary.myFunction)
- The log displays
Foo
- Edited the library:
function myFunction() {return "Bar"}
- Re-ran the including script, the log now displays
Bar
So it really is quite simple after the initial setup. See this folder on my Google Drive for a real example.
Also see the Google documentation for libraries.
According to https://developers.google.com/gmail/add-ons/how-tos/publish to allow other users on your domain to install your add-on you should give them the deployment ID.
Publishing Gmail Add-ons
Publishing add-ons allows them to be used by other users. While a few
add-ons have been made available in the G Suite Marketplace for users
to install, it is not currently possible to publish your own add-on to
the Marketplace.
In the meantime, you can install add-ons you have developed to test
them. You can also install add-ons created by other users in your
domain if they give you the add-on's deployment ID.
If you'd like your add-on to be considered for publication, please
fill out this form to be notified as we begin accepting additional
listings.
The instructions for installing unplublished add-ons are published on https://developers.google.com/gmail/add-ons/how-tos/install-unpublished
Best Answer
I use this option to install my Gmail add-on on the Google accounts I use while on development, prior to publishing.
Check-out this link https://developers.google.com/gsuite/add-ons/how-tos/testing-gsuite-addons#install_an_unpublished_add-on
I don't know how it works for editor add-ons, but for my Gmail/Gsuite add-on, it's pretty straightforward. I can use this option to install on any G Suite account from the same domain, and any Gmail account, provided I share the project with the account first.