By the way, if you create your own scripts, do you have a function you want to use in common?
Also, are there any cases where you want to create a wrapper library for an external library?
In that case, I think it’s good to make your own library with GAS. This time I will introduce how to make a library.
What is Library？
A library is a packaged collection of processes for a specific purpose.
PyPI (Python Package Index) is famous for python.
With the original JS, it is managed by cdn or npm.
How to use and manage libraries in GAS
By the way, I will first introduce how to use and manage the library of people with GAS.
How to import the library
Step1: Click Resource → Library
Step2: Enter the script ID in Add a library in the pop-up [library] (You can also use the project key, but the project key itself is no longer supported)
Step3: Select version and save
I think that there is no problem if you select the basic latest version as the version.
How to use the introduced library
Well, the import of the external library is over. The following is a description of how to actually use it in the script.
【Basic syntax form】
Basically, it can be executed in the form of method call (.function name () (dot + function name)) after the library identifier (Identifier).
Where can I find the Identifier?
When you click the library, a list of libraries that can be used now (imported libraries) is displayed as shown below, and the identifier (Identifier) is described in it. You can rename this yourself.
In the case of the image bellow, “library1” is the identifier name.
Well, first I looked at how to use an external library.
Next time, I will introduce major ones in external libraries.
Related articles： Library ~Using external library and creating your own library~
We will introduce how to use external libraries and how to create your own libraries. Easier development by utilizing an external library and how to reuse common functions by creating a self-made library.
- Part 1: How to use libraries
- Part 2: GAS major external libraries
- Part 3: How to make a self-made library
- Part 4: Tips and points to note when creating a library