Managing Libraries with Google Apps Script

At last we can now create a library of useful stuff in GAS and access it (or share it) from other sheets. Those of you that have seen this blog or follow the parent web site, may have seen some of the Google Apps Script from Excel migration projects and the associated code.

Using this new library management capability in GAS, I can now make all this code available across future projects and to anyone else who want to use it just by referencing the projects key (my shared libraries can be accessed using key MEQ3tE5y5_cTOAgUbUKSIAiz3TLx7pV4j). If you are sharing your code, remember to set up the containing documents level of sharing (private, public with everyone etc)

How to create a library that can be shared
Go to the manage versions menu item of the file menu in the script editor

Save a version of your library

Take a note of the projects Key from the File/Project Properties dialog

How to Use a shared library
Create a new document that is going to access this library, and bring up the Manage Libraries dialog in the script editor.

Add a reference to the shared library. You’ll see whichever versions are available. If you leave development mode off, then your usage will be frozen to the version you select. You can change the Identifier to something else if you like. Its purpose is to nominate the namespace you will use to reference the shared functions. In this library shown all calls will be prefixed with the Mcpher namespace identifier – for example Mcpher.isEmpty().  



Look at the documentation
If the library has been commented using jsDoc, then usage documentation will have been automatically generated and is accessible by clicking on the Title link for each included library. jsDoc also enables autocomplete when you call up the functions in the code you write using the library.

Use the library


I’ll be adding to this library over time – it will eventually contain all the GAS code referred to on the ramblings site, and I’ll also be improving the jsDocumentation available for the shared libraries. Please contact me at the ramblings forum if you have any questions.

References
Project Key :
MEQ3tE5y5_cTOAgUbUKSIAiz3TLx7pV4j

Source code:
https://script.google.com/d/1hhJ8M6z99XccL8WRq2d24-pWGwhq8EfYNaQIQV0CEe5gE1HbBoF4X9W_/edit

Author: brucemcp

Leave a Reply

Your email address will not be published. Required fields are marked *