Skip to content

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.

Read chapter 1

Contents

The learning path

  1. Part 1

    Getting started

    1. 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.
    2. 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.
  2. Part 2

    JavaScript and the runtime

    1. 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 ||.
    2. 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.
    3. 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.
    4. 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.
  3. Part 3

    Reliable automations

    1. 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.
    2. 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.
    3. 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).
    4. 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.
    5. 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.
    6. 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.
    7. 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.
  4. Part 4

    Workspace services

    1. 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.
    2. 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.
    3. 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.
    4. 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.
    5. 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.
    6. 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.
    7. 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.
  5. Part 5

    User interfaces

    1. 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.
    2. 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.
    3. 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.
    4. 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.
    5. 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.
  6. Part 6

    Development and operations

    1. 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.
    2. 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.
    3. 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.
    4. 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.
    5. 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.
    6. 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.
  7. Part 7

    Advanced integrations and data

    1. 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.
    2. 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.
    3. 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.
    4. 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.
    5. 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.
    6. 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.
  8. Part 8

    Reference and glossary

    1. 38 Reference, glossary, and troubleshooting Find the right Apps Script term, service reference, example, or troubleshooting guide when maintaining a production script.