Introduction
Since Google Apps Script can do various things for free, it tends to be a story like “let’s do everything with GAS”. Google Apps Script is also not a panacea, so we recommend that you understand its strengths and weaknesses and use them in comparison with other options.
Now that you have created 2–30 Google Apps Script projects, let’s put together our practices.
This content includes the content at the time of the presentation at Cloud Next ’18 in Tokyo. Since more than half a year has passed since this presentation, the update part is also summarized below.
Strengths and weaknesses of Google Apps Script
First, let’s summarize our strengths and weaknesses.
Strength 1. Easy to call Google Apps API
I think this is my greatest strength. Google Apps Script makes it easy to call Google Apps APIs such as Spreadsheet, Gmail, and Calendar. Since you can call the API without writing any authentication code, you can create what you want with about 30 lines of code.
Strength 2. Can be closed and published to G Suite domain
You can create a web page with Google Apps Script, but there are cases where you want to close it and publish it internally, for example, by displaying a Spreadsheet such as a list of employees on the web. With Google Apps Script, it is possible to publish by closing the disclosure range to the G Suite domain, so you do not have to write the authentication process again, and you can create a secure system without any thought.
Strength 3. Free
I think it’s the main reason why “you can do anything with Google Apps Script”, but although Google Apps Script has limitations (described later), you can use it for free. You can easily create websites and APIs, so you want to publish anything with Google Apps Script.
Strength 4. Easy to deploy
Similar to other FaaS such as Google Cloud Functions, basically saving the function and deploying it is very easy to deploy. It is recommended that you can push locally developed ones like Git by using the clasp.
Weaknesses 1. Various restrictions due to allocation
There are limits such as the execution time per day and the number of calls to various Google Apps APIs. This quota (Quotas) seems to be in the process of being relaxed, but it should be implemented carefully.
Quotas for Google Services | Apps Script | Google Developers
Under the flexible quota system, such hard quota limits are removed.Scripts do not stop when they reach a quota limit…
developers.google.com
Weakness 2.npm is not standard
Since Google Apps Script can be written in JavaScript, I would like to use the npm package, but I can not use the npm package as a standard function. Some people have created converters so that they can be used with Google Apps Script, but there are cases in which those that use the Core API of Node.js cannot be used even after conversion.
Criteria for choosing Google Apps Script
So in what cases should you use Google Apps Script? Lists the elements that are the basis of judgment.
1. Whether it is a process related to Google Apps
The first is whether you can take full advantage of Google Apps Script. I think it’s better to use Google Apps Script for processing related to Google Apps, but if not, let’s choose other FaaS such as Google Cloud Functions. For example, it is often better to select Google Cloud Functions for processing related to GCP services.
2. Can it be realized with the standard functions of Google Apps?
Various functions are provided in Google Apps, and I think there are many unexpectedly unknown functions. For example, Spreadsheet can extract data from other sheets into SQL-like with the QUERY function, and translate it with the GOOGLE TRANSLATE function. Google Docs also has features such as voice input. First of all, it’s a good idea to consider whether it can be realized with standard functions. Also, as add-ons can be added to Google Apps recently, these are good options to consider.
3. Doesn’t the code amount become huge?
In my case, I will consider whether to use Google Apps Script with about 100 lines of code as a guide. I develop the Google Apps Script locally and deploy it with a clasp to check the behavior, so if the code becomes bloated, it will be difficult to debug and maintenance cost will be high. Also, as the code amount increases, the Google Apps Script editor becomes heavy, so it is recommended to keep the code to a minimum.
4. Doesn’t it have complex processing that makes npm desirable?
You can’t use npm with Google Apps Script, so if you need npm, it’s a good idea to include npm-enabled Google Cloud Functions. The API of Google Apps is not so easy as Google Apps Script, but it can be tapped from Google Cloud Functions and so on, so it is one of the ways to have a hard time with authentication and have fun with the library.
5. Is it acceptable even if the worst fail?
Google Apps Script may have quotas and occasionally encounter unintended errors. For example, it is better to think of an appropriate architecture without implementing critical processing in Google Apps Script when a payment fails.
6. I want to make it for free
If you want to make it for free, I think Google Apps Script will be a powerful choice. By the way, Google Cloud Functions also has a large free frame, such as free calls up to 2 million calls per month (at the time of article writing), so you should consider this option.
Pricing | Cloud Functions Documentation | Google Cloud
Cloud Functions pricing is based on how long the function runs, how many times the function is called, and how many resources are provisioned for the function. Depending on the function you are using, send the network …
cloud.google.com
Summary
The above is a summary of the strengths and weaknesses of Google Apps Script, the cases that maximize their effectiveness, and the cases where it is better to choose other options.
I wrote variously, but I think Google Apps Script is a powerful service for linking Google Apps and will be used in the future in the context of RPA, so please feel free to try it.