Preface

If you are reading this book, there is a good chance you have heard of Google and its powerful office productivity suite, Google Apps. Google offers search, email, word processing, and hundreds of other cloud applications and services that are available to individuals but can scale all the way up to serve massive corporations and governments. As one of Google’s most popular services, Google Apps offers some of the best online office products available; they’re an excellent example of web-based applications that outperform legacy desktop software.

This book is about Google Apps Script, which is a service that runs from Google Apps, like Sites and Documents. Google Apps Script is extremely powerful when automating many of the tasks required by day-to-day spreadsheet operations, but it also scales up to provide a complete application platform. If you are coming from a Microsoft Office environment, you can think of it as the macros for Google Docs, but unlike simple macros in MS Office, Google Apps Script has a mature online editor with all the features one would expect in a development platform. Unleash Google Script’s user interface capability and you can create entire data-driven websites and applications that run across most modern browsers, including mobile ones.

In addition to the integrated development environment (IDE), Google Apps Script comes with a manager for organizing scripts, built-in debugging, automatic code completion, timed event triggers, and automated revisioning, to name a few features. What really caught this author’s attention was that everything is web-based. There is no need to download and configure a code editor or transport development files from computer to computer, wasting time resynchronizing files and reconnecting libraries. Simply sign into your Google account and start creating. Google Apps Scripts are written in JavaScript, so there is no need to compile the code, making application development very fast.

With its own set of libraries, Google Apps Script can interact with most of the services provided by Google, making it the “Swiss Army knife” behind the main products. Other application-building methods for accessing Google products, such as App Engine and the gData APIs (offered in many different languages), all require a place for you to develop and deploy your code. With Google Apps Script, you are building the code into the existing Google platform, and that provides a robust experience where your products inherit Google’s legendary 99.9 percent availability. Because there is no need to have anything more than a basic Internet-connected browser, development on this platform is something anyone can get started with, without any up-front expense. Google Apps Script is not locked inside Google, where it can only talk to Google servers; rather, it can communicate through JDBC, JSON, and SOAP, and it has a urlFetch method, making it very versatile when communicating across the Web.

At Google I/O 2012 a new feature called HTML Service was unveiled, giving Google Apps Script programmers the ability to build custom user interfaces that can run inside a spreadsheet window as a Google gadget or completely independently in a browser. Talk about earth-shattering: a cloud programing platform that can access just about any web-based service and has the ability to create AJAX-style web pages? That is noteworthy. To date, Google Apps Script is the only way to gain full access to Gmail at the message level, and more services are added every year.

This book will focus on teaching you how to build powerful web applications using Google Apps Script. It is laid out in sections that explain how the different parts of Google Apps Script work and puts all these together in a series of fully functional applications that you can put to work right away.

Who Should Read This Book

This book is perfect for anyone who wants to extend what can be done with Google Apps but is not ready to dive into the complicated world of the Google Web Toolkit and Java APIs. You don’t have to be a webmaster or programmer to grasp the concepts in this book. Google Apps Script takes care of server configuration, gives you a place to save your projects, and allows you to start developing immediately. This book is approachable by anyone with basic coding skills and a fundamental understanding of JavaScript. If you have never used JavaScript, I recommend having a copy of Head First JavaScript (O’Reilly) close at hand to help you through concepts like variables, arrays, and objects. All the application examples have highly detailed explanations, so if you are a Google Apps power user, you should not have difficulty grasping the content in this book and writing incredible applications using Google Apps Script.

What You Will Need

You will need a web browser (I recommend Chrome) and any type of Google account. That’s it! Google Apps Script is a completely web-based solution that is free and ready for you to start programming today.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.

Tip

This element signifies a tip or suggestion.

Note

This element signifies a general note.

Warning

This element indicates a warning or caution.

Using Code Examples

At the end of each chapter you will find the full code used to create that chapter’s project. In addition, you may access all the files used to create this book in the book’s Drive folder.

This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing a CD-ROM of examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Google Apps Script by James Ferreira (O’Reilly). Copyright 2014 James Ferreira, 978-1-491-94618-3.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at permissions@oreilly.com.

O’Reilly Safari

Note

Safari (formerly Safari Books Online) is a membership-based training and reference platform for enterprise, government, educators, and individuals.

Members have access to thousands of books, training videos, Learning Paths, interactive tutorials, and curated playlists from over 250 publishers, including O’Reilly Media, Harvard Business Review, Prentice Hall Professional, Addison-Wesley Professional, Microsoft Press, Sams, Que, Peachpit Press, Adobe, Focal Press, Cisco Press, John Wiley & Sons, Syngress, Morgan Kaufmann, IBM Redbooks, Packt, Adobe Press, FT Press, Apress, Manning, New Riders, McGraw-Hill, Jones & Bartlett, and Course Technology, among others.

For more information, please visit http://oreilly.com/safari.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

  • O’Reilly Media, Inc.
  • 1005 Gravenstein Highway North
  • Sebastopol, CA 95472
  • 800-998-9938 (in the United States or Canada)
  • 707-829-0515 (international or local)
  • 707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at http://oreil.ly/google-script.

To comment or ask technical questions about this book, send email to bookquestions@oreilly.com.

For more information about our books, courses, conferences, and news, see our website at http://www.oreilly.com.

Find us on Facebook: http://facebook.com/oreilly

Follow us on Twitter: http://twitter.com/oreillymedia

Watch us on YouTube: http://www.youtube.com/oreillymedia

Get Google Apps Script, 2nd Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.