Book Image

Learning Google Apps Script

By : Ramalingam Ganapathy
Book Image

Learning Google Apps Script

By: Ramalingam Ganapathy

Overview of this book

Google Apps Script is a cloud-based scripting language based on JavaScript to customize and automate Google applications. Apps Script makes it easy to create and publish add-ons in an online store for Google Sheets, Docs, and Forms. It serves as one single platform to build, code, and ultimately share your App on the Web store. This book begins by covering the basics of the Google application platform and goes on to empower you to automate most of the Google applications. You will learn the concepts of creating a menu, sending mails, building interactive web pages, and implementing all these techniques to develop an interactive Web page as a form to submit sheets You will be guided through all these tasks with plenty of screenshots and code snippets that will ensure your success in customizing and automating various Google applications This guide is an invaluable tutorial for beginners who intend to develop the skills to automate and customize Google applications
Table of Contents (16 chapters)
Learning Google Apps Script
Credits
About the Author
About the Reviewer
www.PacktPub.com
Preface
Index

Google Apps Script


You can customize or automate Google Apps using the JavaScript scripting language with Google-defined classes, known as Google Apps Script (GAS). Google implements GAS based on JavaScript 1.6 with some portions of 1.7 and 1.8. The GAS services and APIs provide easy access so users can automate tasks across Google products and third-party services.

You can write code in Google Docs, Sheets, and Forms using GAS and can automate tasks similar to what Visual Basic for Applications does in Microsoft Office. However, GAS runs on Google's server and the results are rendered in your browser. The integrated script editor allows you to edit and debug your scripts within your browser, and you do need not install anything. You can activate your debugged and tested script functions to run either based on your interactions or based on a trigger in response to an event or timed intervals (in minutes, hours, days, weeks, future dates, and so on). These events include onOpen, onEdit, onInstall, and many more. GAS is also used to create add-ons for Docs, Sheets, and Forms.

GAS can help you with every aspect of automating a task—you can even use it to order a pizza at predetermined date/time!

Visual Basic for Applications

Microsoft implements Visual Basic for Applications (VBA) to help automate Office applications such as Excel and Word. For each respective application, VBA is known as Excel VBA or Word VBA and so on. Using Excel VBA, you can create macros for Excel known as "Excel macros". GAS is for Google Applications, and operates in the same way as VBA does for Microsoft Office applications. Although both VBA and GAS do not require a separate compilation process, they are very different scripting languages and use different programming APIs, methods, and properties.

I hope many of you are familiar with using VBA for Office applications; if not, then never mind—that's not an obstacle to learning GAS.

The advantages of GAS over VBA

  • Version-independence: Sheets/Docs along with scripts are automatically saved in the cloud, attached to your Google account, and accessible from any computer with a browser. There is no need to worry whether the other computer has the same version of Sheets/Docs installed or not, whereas we can never be sure that one version of the Excel/Word macros will work on another version.

  • Platform-independence: When you create VBA macros in Excel/Word on the Windows platform, they may not work on the Mac platform and vice versa. With Google Sheets/Docs, it doesn't matter what platform you're working on—it'll work.

The limitations of GAS

GAS runs on Google's server, so it cannot run continuously for more than six minutes (this may vary in the future). All of your functions should finish running and should return results within this time limit. Don't panic, as you'll learn how to use triggers effectively to overcome these limitations later.

In the following sections, we will take a look at the most popular Google Apps and how we can use GAS to customize and/or automate tasks.