Apps Script book
Comprehensive Apps Script
Learn Google Apps Script through small examples: build a maintainable Sheets request tracker, chapter by chapter, from first script to deployment.
38 chapters 8 parts
Start here
Build from a first function to a maintainable workflow.
Each chapter keeps setup, expected results, and source files beside the explanation.
Contents
The learning path
Part 1
Getting started
- 01 Orientation Choose between bound and standalone Apps Script projects, and learn what the V8 runtime lacks and which Workspace data a script can access.
- 02 Run your first Sheets script Run your first bound Apps Script: read a small Customers sheet tab into the execution log and inspect the logged two-dimensional array.
Part 2
JavaScript and the runtime
- 03 Work with JavaScript values and objects Update a request object in Apps Script and log how strings, numbers, booleans, null, and undefined compare, convert, and fall back with ?? and ||.
- 04 Make decisions with functions and loops Write Apps Script helper functions that take parameters, return a decision, branch with if, and stop a while loop after a fixed number of passes.
- 05 Work with JavaScript arrays Build an active-customer summary from a 2D array like the one Range.getValues() returns. Find columns by header name, then map and filter rows.
- 06 Understand the runtime and permissions Compare two Apps Script projects to see where code runs, what a bound project adds, and how the manifest, OAuth scopes, and running account limit access.
Part 3
Reliable automations
- 07 Read and write Sheets in batches Update the status column of a Sheets request table with one getValues() read and one setValues() write, after checking the headers and array shape.
- 08 Write custom functions for Sheets formulas Write Apps Script custom functions that Sheets formulas call, accept a cell or a range, fill cells with a 2D array, and stay inside their limits.
- 09 Validate, highlight, and react to Sheets edits Add dropdowns, checkboxes, and conditional formatting to a Google Sheets table with Apps Script, and timestamp status edits with onEdit(e).
- 10 Fetch data from web APIs Use UrlFetchApp.fetch() in Apps Script to import a JSON weather forecast into a Sheets range and read a limited number of GitHub API pages.
- 11 State across runs with PropertiesService Store state across Apps Script runs with PropertiesService, CacheService, and LockService for durable script properties, per-user keys, and caches.
- 12 Install and remove time-driven triggers Install one hourly Apps Script trigger that marks blank request statuses Ready, check for an existing trigger before creating one, then remove it.
- 13 Build a Sheets request tracker Build a Sheets request tracker that validates its table, marks New rows Ready with a timestamp in one batch write, and runs from a menu or hourly trigger.
Part 4
Workspace services
- 14 DriveApp files, folders, and scopes Copy a Google Doc by ID with DriveApp and save the copy's ID, then see how Google Picker and the drive.file scope give access to one picked file.
- 15 Generate a Docs report from a template Copy a Docs template with DriveApp, fill its placeholders and add a formatted table with DocumentApp, and save the report ID so reruns skip the copy.
- 16 Prepare Gmail work before sending Build an Apps Script project that lists labeled test messages, creates review drafts with createDraft(), and saves each message's state.
- 17 Create and update Calendar events Create a timed and an all-day event on a practice calendar with CalendarApp, store each iCalUID, and update the same events on later runs.
- 18 Google Forms scripts and response triggers Build a Google Form in Apps Script with FormApp, add branching and quiz items, and handle form-submit trigger responses without duplicate work.
- 19 Build a two-slide garden briefing Build a two-slide Google Slides briefing with SlidesApp that places text, shapes, a line, and a PNG map, then resizes the map by its saved object ID.
- 20 Inspect a folder with Advanced Drive v3 Enable the Advanced Drive service in Google Apps Script and call Drive.Files.list with pageToken to inspect metadata from a selected Drive folder.
Part 5
User interfaces
- 21 Menus, sidebars, and modals Build a custom Sheets menu with onOpen() and createMenu(), then open an alert, a sidebar, and a modal dialog with HtmlService in Google Apps Script.
- 22 Build a private request-status web app Build a private web app form that looks up a request in a spreadsheet, checks the ID on the server, and shows the result as plain text.
- 23 HTTP endpoints and webhooks with doPost Handle HTTP requests and webhooks in Apps Script with doGet and doPost, test redirected web-app URLs, and verify HMAC-signed JSON payloads.
- 24 Build a personal Workspace add-on Build a Workspace add-on that shows a handoff checklist in the Drive side panel with CardService and saves it per user, without reading Drive files.
- 25 Install and release a Workspace add-on Install the Drive checklist add-on for testing, rehearse a versioned release with a draft tester, and prepare the Marketplace listing and OAuth settings.
Part 6
Development and operations
- 26 Use the myFunction editor extension Install the myFunction Chrome extension, review what it can access, and use its diagnostics, navigation, and formatting on a small Sheets project.
- 27 Debug executions and recover from limits Debug Google Apps Script with breakpoints, Logger.log, and execution history, then resume a read-only batch audit from its checkpoint after a failure.
- 28 Local Apps Script development with clasp Set up a local Apps Script project with clasp 3.4.1 and Git, snapshot a bound script, review the upload list, and push a reviewed revision.
- 29 Test Apps Script code locally and in Sheets Extract pure helpers from Apps Script services, run fast local unit tests with Node's test runner, and verify Sheets integration in a disposable test tab.
- 30 TypeScript for Google Apps Script Write and compile TypeScript for Google Apps Script with @types/google-apps-script and clasp, configure tsconfig.json, emit .gs code, and upload.
- 31 Share a versioned Apps Script library Build a reusable Google Apps Script library project, attach it by Script ID at a pinned version, and manage consumer upgrades and rollbacks.
Part 7
Advanced integrations and data
- 32 OAuth for separate accounts Read a private sheet in Apps Script with a dedicated Google OAuth client, store and revoke its tokens, and compare service-account impersonation.
- 33 Use AI models from Apps Script Classify, extract, and summarize Google Sheet rows with Gemini, OpenAI, or Claude in Apps Script using UrlFetchApp, validated JSON, and human review.
- 34 Answer a request in Google Chat Build a private Apps Script Chat app that looks up fictional requests, replies with a card, updates it on a button click, and logs its removal.
- 35 GitHub issues and Actions events Call the GitHub REST API from Google Apps Script with UrlFetchApp and a scoped token, then receive an authenticated receipt from GitHub Actions.
- 36 Keep one Sheets chart up to date Build one embedded Sheets chart with Sheet.newChart() in Apps Script, save its chart ID, and update its legend without inserting duplicate charts.
- 37 Package CSV, JSON, and a PDF for handoff Build one ZIP in Apps Script with checked CSV, a JSON manifest, and a Google Doc converted to PDF with getAs(), then verify the saved file.
Part 8
Reference and glossary