Unit 3 · Module 2
The Apps Script Naming Convention
The cheat sheet — every Google product’s host global, the getActive pattern, and the capitalization rules
The XxxApp pattern
Every Google product gets a host global named after itself with
App appended. The global is always capitalized, always ends in
App, and is always available without an import.
| Google product | Host global | First call you usually make |
|---|---|---|
| Sheets | SpreadsheetApp | .getActiveSpreadsheet() |
| Docs | DocumentApp | .getActiveDocument() |
| Forms | FormApp | .getActiveForm() |
| Slides | SlidesApp | .getActivePresentation() |
| Gmail | GmailApp | .getInboxThreads() or .sendEmail(...) |
| Calendar | CalendarApp | .getDefaultCalendar() |
| Drive | DriveApp | .getFiles() or .getFolderById(...) |
| Contacts | ContactsApp | .getContacts() |
| Maps | Maps | .newGeocoder() (one of the few exceptions to XxxApp) |
The getActive___() pattern
Most XxxApp globals expose a getActive___() method.
It returns the document the script is bound to (see Page 1). If the
script is standalone — not attached to any document — these calls return
null and you have to open something explicitly by ID or URL instead.
| Bound script | Standalone equivalent |
|---|---|
SpreadsheetApp.getActiveSpreadsheet() | SpreadsheetApp.openById(“abc123”) |
DocumentApp.getActiveDocument() | DocumentApp.openById(“abc123”) |
FormApp.getActiveForm() | FormApp.openById(“abc123”) |
Capitalization rules
Apps Script follows standard JavaScript convention with one twist worth naming explicitly.
A note on camelCase below: it’s the standard JavaScript
style of writing a multi-word name as one word, lowercase first letter, with
each later word starting with a capital. getActiveSpreadsheet
is camelCase. orderRange is camelCase. It contrasts with
capital-first names like SpreadsheetApp.
| What it is | Case | Example |
|---|---|---|
| Host global | Capitalized, ends in App | SpreadsheetApp |
| Method on a host global | camelCase, starts with a verb | getActiveSpreadsheet() |
| Class returned by a method | Capitalized, no App suffix | Spreadsheet, Sheet, Range |
| Developer’s variable | camelCase, any name | sheet, orderRange |
Reading the cheat sheet in code
Putting the three patterns together — a script that bumps a counter in a Sheet and emails the result:
Apps Script
function bumpCounter() {
const spreadsheet = SpreadsheetApp.getActiveSpreadsheet();
const sheet = spreadsheet.getSheetByName("Counter");
const cell = sheet.getRange("A1");
const current = cell.getValue();
cell.setValue(current + 1);
GmailApp.sendEmail("me@example.com", "Counter bumped", `Now at ${current + 1}`);
} SpreadsheetApp,GmailApp— host globals, capital +App.getActiveSpreadsheet,getSheetByName,getRange,getValue,setValue,sendEmail— methods, camelCase verbs.spreadsheet,sheet,cell,current— developer-named variables."Counter","A1","me@example.com"— values the host reads; typos here break things silently.