DiscoveryVIP / Apps Script AcademyHelp

Apps Script service method reference

Documented local subset. Google references checked 2026-11-18; no live account integration testing occurred. User/document property scopes share a fictional store, cache is per-run, there is one workbook and one document tab, and advanced Drive/Forms/Slides behavior is outside the adapter. Unsupported methods fail rather than fabricate success.

SpreadsheetApp.getActiveSpreadsheet

Find the workbook in the current bound context; a standalone or web-app context may need openById.

Parameters
none
Returns
Spreadsheet or null
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

SpreadsheetApp.openById

Open the workbook identified by a validated configured ID.

Parameters
id: string workbook ID
Returns
Spreadsheet
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Selecting the first tab exposes its body. The fictional template has no second tab.
function main() {
  const doc = DocumentApp.openById("template");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

SpreadsheetApp.getActiveSheet

Retrieve the currently active tab; its identity can change.

Parameters
none
Returns
Sheet
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

SpreadsheetApp.newDataValidation

Start a rule builder before assigning the built rule to a Range.

Parameters
none
Returns
DataValidationBuilder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The rule documents the two permitted statuses and rejects invalid input in Google’s UI.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const rule = SpreadsheetApp.newDataValidation().requireValueInList(["Pending", "Complete"]).setAllowInvalid(false).build();
  sheet.getRange("B2:B4").setDataValidation(rule);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

SpreadsheetApp.getUi

Access the host spreadsheet UI for menus, prompts, dialogs or sidebars.

Parameters
none; spreadsheet-bound editor context
Returns
Ui
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The menu stores a valid handler name. Production onOpen should call the menu-creation function.
function main() {
  SpreadsheetApp.getUi().createMenu("Workshop").addItem("Update statuses", "updateStatuses").addToUi();
}
function updateStatuses() {
  SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("B2:B4").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Spreadsheet.getActiveSheet

Select the active sheet within this workbook.

Parameters
none
Returns
Sheet
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Spreadsheet.getSheets

Return all sheet objects in tab order.

Parameters
none
Returns
Sheet[]
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getSheets returns Sheet objects. Each has getName, not the invented getNames method.
function main() {
  const book = SpreadsheetApp.getActiveSpreadsheet();
  const sheets = book.getSheets();
  console.log(sheets.map(sheet => sheet.getName()).join(", "));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Spreadsheet.getSheetByName

Find a tab by exact name and check for null before chaining.

Parameters
name: exact string
Returns
Sheet or null
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Case and spelling matter. The explicit guard gives a useful message instead of a null-property error.
function main() {
  const book = SpreadsheetApp.getActiveSpreadsheet();
  const sheet = book.getSheetByName("Sales");
  if (!sheet) throw new Error("Sales sheet missing");
  console.log(sheet.getName());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Spreadsheet.insertSheet

Create a new tab without overwriting an existing tab.

Parameters
name: nonempty unique string
Returns
Sheet
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The numeric total is written into a separate two-by-two report, leaving Sales intact.
function main() {
  const book = SpreadsheetApp.getActiveSpreadsheet();
  const rows = book.getSheetByName("Sales").getDataRange().getValues().slice(1);
  const total = rows.reduce((sum, row) => sum + row[1], 0);
  const report = book.getSheetByName("Report") || book.insertSheet("Report");
  report.getRange("A1:B2").setValues([["Metric", "Value"], ["Sales total", total]]);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Spreadsheet.getId

Read the stable workbook ID rather than its visible title.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The created document contains a visible paragraph and receives a locally unique identifier.
function main() {
  const doc = DocumentApp.create("Workshop notes");
  doc.getTabs()[0].asDocumentTab().getBody().appendParagraph("First meeting");
  console.log(doc.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Spreadsheet.setActiveSheet

Change the active tab explicitly.

Parameters
sheet: Sheet belonging to this workbook
Returns
Sheet
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Sheet.getName

Read a sheet tab name.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The normal sequence reaches Finished. An exception interrupts subsequent statements; it is not a Google authorization dialog.
function main() {
  console.log("Starting");
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  console.log(sheet.getName());
  console.log("Finished");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Sheet.getRange

Select a rectangle; numeric coordinates start at one and trailing dimensions are sizes.

Parameters
a1: string OR row: positive integer, column: positive integer, numRows?: positive integer, numColumns?: positive integer
Returns
Range
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Sheet.getDataRange

Select the used rectangular data area, which may include headers.

Parameters
none
Returns
Range
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
slice(1) excludes exactly the header; slicing from two also loses Alex’s record.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sales");
  const rows = sheet.getDataRange().getValues();
  console.log(rows.slice(1));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Sheet.getLastRow

Read the last used row coordinate; it is not a count of business records.

Parameters
none
Returns
integer
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The new row increases the used row count by one and preserves existing people.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.appendRow(["Sam", "Pending"]);
  console.log(sheet.getLastRow());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Sheet.getLastColumn

Read the last used column coordinate.

Parameters
none
Returns
integer
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Sheet.appendRow

Append one row of values after the used rows.

Parameters
rowContents: one-dimensional array
Returns
Sheet
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The new row increases the used row count by one and preserves existing people.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.appendRow(["Sam", "Pending"]);
  console.log(sheet.getLastRow());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Sheet.deleteRow

Remove one row and shift later row coordinates upward.

Parameters
rowPosition: positive integer
Returns
Sheet
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Sheet.insertRowBefore

Insert a blank row before the selected position.

Parameters
beforePosition: positive integer
Returns
Sheet
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.getSheet

Return the sheet containing this range.

Parameters
none
Returns
Sheet
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.getRow

Read the one-based top row coordinate.

Parameters
none
Returns
integer
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The prepared edit event identifies row two. Selecting Manual deliberately tests the missing-event guard.
function main() {
  onEdit(e);
}
function onEdit(event) {
  if (!event || !event.range) throw new Error("Choose an onEdit event");
  console.log(event.range.getRow());
  console.log(event.value);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.getColumn

Read the one-based left column coordinate.

Parameters
none
Returns
integer
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.getValue

Read the top-left cell value, not every cell in the range.

Parameters
none
Returns
cell value
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The getter reads the value written earlier in the same run, so the console confirms the state change.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B3").setValue("Complete");
  console.log(sheet.getRange("B3").getValue());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.getValues

Read a rectangular two-dimensional array, preserving primitive cell types.

Parameters
none
Returns
Object[][]
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Starting at row two excludes the header. The range contains two rows and two columns.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sales");
  const range = sheet.getRange(2, 1, 2, 2);
  console.log(range.getValues());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.setValue

Set the value of each selected cell; this changes existing content.

Parameters
value: supported cell value
Returns
Range
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.setValues

Write an exactly matching row/column matrix in one explicit operation.

Parameters
values: rectangular Object[][] matching dimensions
Returns
Range
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Three one-cell rows match a three-by-one range. A two-column target would reject the input.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const matrix = [["Ready"], ["Review"], ["Done"]];
  sheet.getRange(2, 2, matrix.length, 1).setValues(matrix);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.clearContent

Clear cell content while leaving unrelated format settings intact.

Parameters
none
Returns
Range
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.getFormula

Read the top-left formula source, or an empty string for a non-formula cell.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.setFormula

Store a formula for calculation; the simulator supports only selected aggregate formulas.

Parameters
formula: string beginning with =
Returns
Range
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The sum includes all three amounts: 120 + 80 + 200 = 400.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName("Sales");
  sheet.getRange("B6").setFormula("=SUM(B2:B4)");
  console.log(sheet.getRange("B6").getValue());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.setBackground

Change fill color without changing stored values.

Parameters
color: CSS color string
Returns
Range
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Chained formatting methods return the same range, so both styles apply to the header.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("A1:B1").setBackground("#dcefe5").setFontWeight("bold");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.setFontWeight

Style the selected text weight without using color as the only signal.

Parameters
fontWeight: normal or bold string
Returns
Range
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Chained formatting methods return the same range, so both styles apply to the header.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("A1:B1").setBackground("#dcefe5").setFontWeight("bold");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.setNumberFormat

Assign number display format; the simulator records it without full Google rendering.

Parameters
numberFormat: string pattern
Returns
Range
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Range.setDataValidation

Attach an input rule to cells; local code records the rule for inspection.

Parameters
rule: built DataValidation
Returns
Range
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The rule documents the two permitted statuses and rejects invalid input in Google’s UI.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const rule = SpreadsheetApp.newDataValidation().requireValueInList(["Pending", "Complete"]).setAllowInvalid(false).build();
  sheet.getRange("B2:B4").setDataValidation(rule);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DataValidationBuilder.requireValueInList

Define allowed dropdown choices.

Parameters
values: string array; showDropdown?: boolean
Returns
DataValidationBuilder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The rule documents the two permitted statuses and rejects invalid input in Google’s UI.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const rule = SpreadsheetApp.newDataValidation().requireValueInList(["Pending", "Complete"]).setAllowInvalid(false).build();
  sheet.getRange("B2:B4").setDataValidation(rule);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DataValidationBuilder.setAllowInvalid

Choose whether invalid input is allowed rather than rejected in Google’s UI.

Parameters
allowInvalidData: boolean
Returns
DataValidationBuilder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The rule documents the two permitted statuses and rejects invalid input in Google’s UI.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const rule = SpreadsheetApp.newDataValidation().requireValueInList(["Pending", "Complete"]).setAllowInvalid(false).build();
  sheet.getRange("B2:B4").setDataValidation(rule);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DataValidationBuilder.build

Return the completed rule for setDataValidation.

Parameters
none
Returns
DataValidation
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The rule documents the two permitted statuses and rejects invalid input in Google’s UI.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  const rule = SpreadsheetApp.newDataValidation().requireValueInList(["Pending", "Complete"]).setAllowInvalid(false).build();
  sheet.getRange("B2:B4").setDataValidation(rule);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DocumentApp.create

Create a new document; repeated calls create multiple persistent files in Google.

Parameters
name: string
Returns
Document
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The created document contains a visible paragraph and receives a locally unique identifier.
function main() {
  const doc = DocumentApp.create("Workshop notes");
  doc.getTabs()[0].asDocumentTab().getBody().appendParagraph("First meeting");
  console.log(doc.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DocumentApp.openById

Open an existing document for which the executing account has access.

Parameters
id: string document ID
Returns
Document
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Selecting the first tab exposes its body. The fictional template has no second tab.
function main() {
  const doc = DocumentApp.openById("template");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Document.getId

Read the document identifier for audit or later access.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The created document contains a visible paragraph and receives a locally unique identifier.
function main() {
  const doc = DocumentApp.create("Workshop notes");
  doc.getTabs()[0].asDocumentTab().getBody().appendParagraph("First meeting");
  console.log(doc.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Document.getTabs

Return top-level tabs; traverse children separately when needed.

Parameters
none
Returns
Tab[]
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Selecting the first tab exposes its body. The fictional template has no second tab.
function main() {
  const doc = DocumentApp.openById("template");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Document.getBody

Access active/first-tab body according to context; this course prefers explicit tab selection.

Parameters
none
Returns
Body
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Selecting the first tab exposes its body. The fictional template has no second tab.
function main() {
  const doc = DocumentApp.openById("template");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Document.saveAndClose

Commit pending changes and close the document handle in Google.

Parameters
none
Returns
void
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Tab.asDocumentTab

Access document-specific content from a generic tab.

Parameters
none
Returns
DocumentTab
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Selecting the first tab exposes its body. The fictional template has no second tab.
function main() {
  const doc = DocumentApp.openById("template");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DocumentTab.getBody

Read the body of the explicitly selected document tab.

Parameters
none
Returns
Body
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Selecting the first tab exposes its body. The fictional template has no second tab.
function main() {
  const doc = DocumentApp.openById("template");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Body.appendParagraph

Append a text paragraph at the end of the body.

Parameters
text: string
Returns
Paragraph
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The created document contains a visible paragraph and receives a locally unique identifier.
function main() {
  const doc = DocumentApp.create("Workshop notes");
  doc.getTabs()[0].asDocumentTab().getBody().appendParagraph("First meeting");
  console.log(doc.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Body.appendListItem

Append a list item; the local preview uses a structural bullet representation.

Parameters
text: string
Returns
ListItem
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The body has a heading, a list item and a two-row table with a distinct owner/task relationship.
function main() {
  const doc = DocumentApp.create("Meeting report");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  body.appendParagraph("Agenda").setHeading(DocumentApp.ParagraphHeading.HEADING1);
  body.appendListItem("Review budget");
  body.appendTable([["Owner", "Task"], ["Alex", "Review"]]);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Body.appendTable

Append a table whose rows and cells are supplied as nested arrays.

Parameters
cells: string[][]
Returns
Table
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The body has a heading, a list item and a two-row table with a distinct owner/task relationship.
function main() {
  const doc = DocumentApp.create("Meeting report");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  body.appendParagraph("Agenda").setHeading(DocumentApp.ParagraphHeading.HEADING1);
  body.appendListItem("Review budget");
  body.appendTable([["Owner", "Task"], ["Alex", "Review"]]);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Body.replaceText

Replace matching text; escape literal metacharacters and check Google RE2 limitations.

Parameters
searchPattern: regex string, replacement: string
Returns
Element
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Only the copy changes. The escaped braces identify the literal NAME placeholder.
function main() {
  const copy = DriveApp.getFileById("template").makeCopy("Letter for Alex");
  const body = DocumentApp.openById(copy.getId()).getTabs()[0].asDocumentTab().getBody();
  body.replaceText("\\{\\{NAME\\}\\}", "Alex");
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Body.getText

Read body text without treating it as live HTML.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Selecting the first tab exposes its body. The fictional template has no second tab.
function main() {
  const doc = DocumentApp.openById("template");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Paragraph.setHeading

Apply a semantic heading style to a paragraph.

Parameters
heading: DocumentApp.ParagraphHeading enum
Returns
Paragraph
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The body has a heading, a list item and a two-row table with a distinct owner/task relationship.
function main() {
  const doc = DocumentApp.create("Meeting report");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  body.appendParagraph("Agenda").setHeading(DocumentApp.ParagraphHeading.HEADING1);
  body.appendListItem("Review budget");
  body.appendTable([["Owner", "Task"], ["Alex", "Review"]]);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DriveApp.createFolder

Create a folder and retain its stable ID; duplicate visible names can exist.

Parameters
name: string
Returns
Folder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
A new file is created inside Archive and renamed; the original brief remains in the root.
function main() {
  const folder = DriveApp.createFolder("Archive");
  const copy = DriveApp.getFileById("brief").makeCopy("Brief copy", folder);
  copy.setName("Reviewed brief");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DriveApp.getFileById

Open one accessible file by stable ID.

Parameters
id: string
Returns
File
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Only the copy changes. The escaped braces identify the literal NAME placeholder.
function main() {
  const copy = DriveApp.getFileById("template").makeCopy("Letter for Alex");
  const body = DocumentApp.openById(copy.getId()).getTabs()[0].asDocumentTab().getBody();
  body.replaceText("\\{\\{NAME\\}\\}", "Alex");
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DriveApp.getFolderById

Open one accessible folder by stable ID.

Parameters
id: string
Returns
Folder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DriveApp.getRootFolder

Access the current user’s My Drive root in Google.

Parameters
none
Returns
Folder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DriveApp.getFilesByName

Find potentially multiple exact-name file matches.

Parameters
name: string
Returns
FileIterator
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The iterator yields the one matching fictional file; an absent name yields zero matches without next being called.
function main() {
  const files = DriveApp.getFilesByName("Brief.txt");
  let count = 0;
  while (files.hasNext()) {
    console.log(files.next().getId());
    count++;
  }
  console.log(count);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

DriveApp.getFoldersByName

Find potentially multiple exact-name folder matches.

Parameters
name: string
Returns
FolderIterator
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The folder is reused if present. The source is copied, so repeated execution can still create duplicate copies to investigate.
function main() {
  const matches = DriveApp.getFoldersByName("Project Alpha");
  const folder = matches.hasNext() ? matches.next() : DriveApp.createFolder("Project Alpha");
  DriveApp.getFileById("brief").makeCopy("Project brief", folder);
  console.log(folder.getName());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

File.getId

Read a file’s opaque identifier.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The created document contains a visible paragraph and receives a locally unique identifier.
function main() {
  const doc = DocumentApp.create("Workshop notes");
  doc.getTabs()[0].asDocumentTab().getBody().appendParagraph("First meeting");
  console.log(doc.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

File.getName

Read the visible file name, which is not guaranteed unique.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The normal sequence reaches Finished. An exception interrupts subsequent statements; it is not a Google authorization dialog.
function main() {
  console.log("Starting");
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  console.log(sheet.getName());
  console.log("Finished");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

File.getMimeType

Read the file content type.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The stable ID returns the correct file even if its visible name later changes.
function main() {
  const file = DriveApp.getFileById("brief");
  console.log(file.getId());
  console.log(file.getName());
  console.log(file.getMimeType());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

File.setName

Rename this file without changing its ID.

Parameters
name: string
Returns
File
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
A new file is created inside Archive and renamed; the original brief remains in the root.
function main() {
  const folder = DriveApp.createFolder("Archive");
  const copy = DriveApp.getFileById("brief").makeCopy("Brief copy", folder);
  copy.setName("Reviewed brief");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

File.makeCopy

Create an independent file copy and preserve the source.

Parameters
name: string, destination?: Folder
Returns
File
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Only the copy changes. The escaped braces identify the literal NAME placeholder.
function main() {
  const copy = DriveApp.getFileById("template").makeCopy("Letter for Alex");
  const body = DocumentApp.openById(copy.getId()).getTabs()[0].asDocumentTab().getBody();
  body.replaceText("\\{\\{NAME\\}\\}", "Alex");
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

File.moveTo

Move a file into a destination the executing account may access.

Parameters
destination: Folder
Returns
File
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

File.getSharingAccess

Inspect coarse sharing access; the local adapter is not a full ACL model.

Parameters
none
Returns
DriveApp.Access
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The normal result remains private. A link-sharing mutation is visible in the audit state.
function main() {
  const file = DriveApp.getFileById("brief");
  file.setSharing(DriveApp.Access.PRIVATE, DriveApp.Permission.VIEW);
  console.log(file.getSharingAccess());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

File.setSharing

Change sharing only after reviewing data exposure and organizational policy.

Parameters
access: DriveApp.Access, permission: DriveApp.Permission
Returns
File
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The normal result remains private. A link-sharing mutation is visible in the audit state.
function main() {
  const file = DriveApp.getFileById("brief");
  file.setSharing(DriveApp.Access.PRIVATE, DriveApp.Permission.VIEW);
  console.log(file.getSharingAccess());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Folder.getId

Read the folder’s stable ID.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The created document contains a visible paragraph and receives a locally unique identifier.
function main() {
  const doc = DocumentApp.create("Workshop notes");
  doc.getTabs()[0].asDocumentTab().getBody().appendParagraph("First meeting");
  console.log(doc.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Folder.getName

Read its potentially nonunique name.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The normal sequence reaches Finished. An exception interrupts subsequent statements; it is not a Google authorization dialog.
function main() {
  console.log("Starting");
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  console.log(sheet.getName());
  console.log("Finished");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Folder.getFiles

Enumerate direct file children rather than recursively traversing folders.

Parameters
none
Returns
FileIterator
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Folder.createFolder

Create a nested child folder.

Parameters
name: string
Returns
Folder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
A new file is created inside Archive and renamed; the original brief remains in the root.
function main() {
  const folder = DriveApp.createFolder("Archive");
  const copy = DriveApp.getFileById("brief").makeCopy("Brief copy", folder);
  copy.setName("Reviewed brief");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Folder.createFile

Create a text file in this folder.

Parameters
name: string, content: string
Returns
File
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

FileIterator.hasNext

Check whether another file is available before calling next.

Parameters
none
Returns
boolean
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The iterator yields the one matching fictional file; an absent name yields zero matches without next being called.
function main() {
  const files = DriveApp.getFilesByName("Brief.txt");
  let count = 0;
  while (files.hasNext()) {
    console.log(files.next().getId());
    count++;
  }
  console.log(count);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

FileIterator.next

Advance the iterator; exhausted iterators must not be read again.

Parameters
none
Returns
File
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The iterator yields the one matching fictional file; an absent name yields zero matches without next being called.
function main() {
  const files = DriveApp.getFilesByName("Brief.txt");
  let count = 0;
  while (files.hasNext()) {
    console.log(files.next().getId());
    count++;
  }
  console.log(count);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

GmailApp.search

Find threads using Google’s query language; local support is subject substrings or one label: term.

Parameters
query: string
Returns
GmailThread[]
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The known matching thread provides sender and body; indexing an empty match list fails.
function main() {
  const threads = GmailApp.search("Invoice");
  const message = threads[0].getMessages()[0];
  console.log(message.getFrom());
  console.log(message.getPlainBody());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

GmailApp.createDraft

Prepare a message for review without delivering it.

Parameters
recipient: string, subject: string, body: string, options?: object including htmlBody
Returns
GmailDraft
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
A valid recipient creates a draft. The quota is a configurable local scenario, not a live account limit.
function main() {
  GmailApp.createDraft("alex@example.com", "Workshop reminder", "Please review your notes.");
  console.log(MailApp.getRemainingDailyQuota());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

GmailThread.getMessages

Retrieve messages within a thread; the local sample has one message per thread.

Parameters
none
Returns
GmailMessage[]
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The known matching thread provides sender and body; indexing an empty match list fails.
function main() {
  const threads = GmailApp.search("Invoice");
  const message = threads[0].getMessages()[0];
  console.log(message.getFrom());
  console.log(message.getPlainBody());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

GmailMessage.getSubject

Read the subject as untrusted message content.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The label selects the invoice thread; an unknown label produces an empty array.
function main() {
  const threads = GmailApp.search("label:Support");
  console.log(threads.length);
  threads.forEach(thread => console.log(thread.getMessages()[0].getSubject()));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

GmailMessage.getPlainBody

Read plain message text without rendering active HTML.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The known matching thread provides sender and body; indexing an empty match list fails.
function main() {
  const threads = GmailApp.search("Invoice");
  const message = threads[0].getMessages()[0];
  console.log(message.getFrom());
  console.log(message.getPlainBody());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

GmailMessage.getFrom

Read sender text; it is not an independent authorization proof.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The known matching thread provides sender and body; indexing an empty match list fails.
function main() {
  const threads = GmailApp.search("Invoice");
  const message = threads[0].getMessages()[0];
  console.log(message.getFrom());
  console.log(message.getPlainBody());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

MailApp.getRemainingDailyQuota

Inspect remaining recipient allowance at this moment; other limits still apply.

Parameters
none
Returns
integer recipient allowance
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
A valid recipient creates a draft. The quota is a configurable local scenario, not a live account limit.
function main() {
  GmailApp.createDraft("alex@example.com", "Workshop reminder", "Please review your notes.");
  console.log(MailApp.getRemainingDailyQuota());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

MailApp.sendEmail

Send real mail only after explicit review in Google; locally it only records a simulated sent entry.

Parameters
recipient: string, subject: string, body: string
Returns
void
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

FormApp.create

Create a new form and retain its ID for later use.

Parameters
title: string
Returns
Form
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The created document contains a visible paragraph and receives a locally unique identifier.
function main() {
  const doc = DocumentApp.create("Workshop notes");
  doc.getTabs()[0].asDocumentTab().getBody().appendParagraph("First meeting");
  console.log(doc.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

FormApp.openById

Open an accessible existing form.

Parameters
id: string
Returns
Form
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Selecting the first tab exposes its body. The fictional template has no second tab.
function main() {
  const doc = DocumentApp.openById("template");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Form.getTitle

Read the visible form title.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The known form has one submitted response; a missing ID is an explicit adapter error.
function main() {
  const form = FormApp.openById("feedback");
  console.log(form.getTitle());
  console.log(form.getResponses().length);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Form.getId

Read the stable form ID.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The created document contains a visible paragraph and receives a locally unique identifier.
function main() {
  const doc = DocumentApp.create("Workshop notes");
  doc.getTabs()[0].asDocumentTab().getBody().appendParagraph("First meeting");
  console.log(doc.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Form.addTextItem

Add a short-text question builder.

Parameters
none
Returns
TextItem
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The new form contains a required text question and is separate from the existing Feedback form.
function main() {
  const form = FormApp.create("Workshop registration");
  form.addTextItem().setTitle("Name").setRequired(true);
  console.log(form.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Form.addParagraphTextItem

Add a long-text question builder.

Parameters
none
Returns
ParagraphTextItem
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The form records two choices for Session and a separate optional long-text response.
function main() {
  const form = FormApp.create("Session choice");
  form.addMultipleChoiceItem().setTitle("Session").setChoiceValues(["Morning", "Afternoon"]).setRequired(true);
  form.addParagraphTextItem().setTitle("Access needs");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Form.addMultipleChoiceItem

Add a single-choice item whose choices need configuration.

Parameters
none
Returns
MultipleChoiceItem
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The form records two choices for Session and a separate optional long-text response.
function main() {
  const form = FormApp.create("Session choice");
  form.addMultipleChoiceItem().setTitle("Session").setChoiceValues(["Morning", "Afternoon"]).setRequired(true);
  form.addParagraphTextItem().setTitle("Access needs");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Form.setDestination

Configure a supported response destination.

Parameters
type: FormApp.DestinationType, id: spreadsheet ID
Returns
Form
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The form stores a fictional workbook destination and a required name question. No real linked sheet is created.
function main() {
  const form = FormApp.create("Attendance");
  form.addTextItem().setTitle("Name").setRequired(true);
  form.setDestination(FormApp.DestinationType.SPREADSHEET, SpreadsheetApp.getActiveSpreadsheet().getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Form.getResponses

Read submissions from a Form, distinct from spreadsheet event arrays.

Parameters
none
Returns
FormResponse[]
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The known form has one submitted response; a missing ID is an explicit adapter error.
function main() {
  const form = FormApp.openById("feedback");
  console.log(form.getTitle());
  console.log(form.getResponses().length);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

FormResponse.getItemResponses

Read question/answer objects for one submission.

Parameters
none
Returns
ItemResponse[]
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Calling getResponse retrieves the answer; printing the function itself is not the submitted answer.
function main() {
  const responses = FormApp.openById("feedback").getResponses();
  responses.forEach(response => response.getItemResponses().forEach(item => console.log(item.getItem().getTitle() + ": " + item.getResponse())));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

ItemResponse.getItem

Identify the question associated with the submitted answer.

Parameters
none
Returns
Item
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Calling getResponse retrieves the answer; printing the function itself is not the submitted answer.
function main() {
  const responses = FormApp.openById("feedback").getResponses();
  responses.forEach(response => response.getItemResponses().forEach(item => console.log(item.getItem().getTitle() + ": " + item.getResponse())));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

ItemResponse.getResponse

Read the submitted answer; type depends on question type.

Parameters
none
Returns
answer value
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Calling getResponse retrieves the answer; printing the function itself is not the submitted answer.
function main() {
  const responses = FormApp.openById("feedback").getResponses();
  responses.forEach(response => response.getItemResponses().forEach(item => console.log(item.getItem().getTitle() + ": " + item.getResponse())));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

CalendarApp.getDefaultCalendar

Access the executing account’s default calendar; locally primary is fictional.

Parameters
none
Returns
Calendar
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The end follows the start by one hour. Reversing it is rejected before recording an event.
function main() {
  const calendar = CalendarApp.getDefaultCalendar();
  calendar.createEvent("Study session", new Date("2026-12-01T14:00:00Z"), new Date("2026-12-01T15:00:00Z"));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

CalendarApp.getCalendarById

Resolve a calendar and check access before creating or reading events.

Parameters
id: string
Returns
Calendar or null
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Calendar.createEvent

Create an interval with end after start; sample exports omit guests and invitations.

Parameters
title: string, startTime: Date, endTime: Date
Returns
CalendarEvent
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The end follows the start by one hour. Reversing it is rejected before recording an event.
function main() {
  const calendar = CalendarApp.getDefaultCalendar();
  calendar.createEvent("Study session", new Date("2026-12-01T14:00:00Z"), new Date("2026-12-01T15:00:00Z"));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Calendar.getEvents

Read events overlapping the requested interval.

Parameters
startTime: Date, endTime: Date
Returns
CalendarEvent[]
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The broad interval overlaps the event; a window ending before the event starts does not.
function main() {
  const calendar = CalendarApp.getDefaultCalendar();
  calendar.createEvent("Review", new Date("2026-12-01T14:00:00Z"), new Date("2026-12-01T15:00:00Z"));
  console.log(calendar.getEvents(new Date("2026-12-01T00:00:00Z"), new Date("2026-12-02T00:00:00Z")).map(event => event.getTitle()));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

CalendarEvent.getTitle

Read event title.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The known form has one submitted response; a missing ID is an explicit adapter error.
function main() {
  const form = FormApp.openById("feedback");
  console.log(form.getTitle());
  console.log(form.getResponses().length);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

CalendarEvent.getStartTime

Read the event start instant; format it in an explicit time zone.

Parameters
none
Returns
Date
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

CalendarEvent.getEndTime

Read the event end instant.

Parameters
none
Returns
Date
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

CalendarEvent.setTitle

Update the title of an existing event.

Parameters
title: string
Returns
CalendarEvent
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The new form contains a required text question and is separate from the existing Feedback form.
function main() {
  const form = FormApp.create("Workshop registration");
  form.addTextItem().setTitle("Name").setRequired(true);
  console.log(form.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

CalendarEvent.setTime

Change an interval after checking ordering and conflicts.

Parameters
startTime: Date, endTime: Date
Returns
CalendarEvent
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

SlidesApp.create

Create a presentation with an initial slide.

Parameters
name: string
Returns
Presentation
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The created document contains a visible paragraph and receives a locally unique identifier.
function main() {
  const doc = DocumentApp.create("Workshop notes");
  doc.getTabs()[0].asDocumentTab().getBody().appendParagraph("First meeting");
  console.log(doc.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

SlidesApp.openById

Open an existing accessible presentation.

Parameters
id: string
Returns
Presentation
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Selecting the first tab exposes its body. The fictional template has no second tab.
function main() {
  const doc = DocumentApp.openById("template");
  const body = doc.getTabs()[0].asDocumentTab().getBody();
  console.log(body.getText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Presentation.getSlides

Retrieve slide objects in order.

Parameters
none
Returns
Slide[]
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The first slide exists and receives a text box. No second slide exists until appended.
function main() {
  const deck = SlidesApp.create("Workshop deck");
  deck.getSlides()[0].insertTextBox("Welcome", 20, 20, 500, 80);
  console.log(deck.getSlides().length);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Presentation.appendSlide

Append a slide and return it for population.

Parameters
layout?: SlidesApp.PredefinedLayout
Returns
Slide
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The default slide introduces Discover and the appended blank slide introduces Experiment.
function main() {
  const deck = SlidesApp.create("Two-part lesson");
  deck.getSlides()[0].insertTextBox("Discover");
  deck.appendSlide(SlidesApp.PredefinedLayout.BLANK).insertTextBox("Experiment");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Slide.insertTextBox

Add positioned text, with Google geometry measured in points.

Parameters
text: string, left?: number, top?: number, width?: number, height?: number
Returns
Shape
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The first slide exists and receives a text box. No second slide exists until appended.
function main() {
  const deck = SlidesApp.create("Workshop deck");
  deck.getSlides()[0].insertTextBox("Welcome", 20, 20, 500, 80);
  console.log(deck.getSlides().length);
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Slide.insertShape

Add a shape whose geometry is separate from its text.

Parameters
shapeType: enum, left: number, top: number, width: number, height: number
Returns
Shape
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The title and labeled rectangle occupy distinct coordinates rather than overlapping at a default location.
function main() {
  const slide = SlidesApp.create("Process diagram").getSlides()[0];
  slide.insertTextBox("Input → Process → Output", 20, 20, 600, 80);
  slide.insertShape(SlidesApp.ShapeType.RECTANGLE, 20, 120, 200, 80).getText().setText("Review");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

HtmlService.createHtmlOutput

Create server-side HTML output rather than a server DOM.

Parameters
html: string
Returns
HtmlOutput
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
A dialog record contains the title and authored HTML. No actual Google dialog opens locally.
function main() {
  const output = HtmlService.createHtmlOutput("<h1>Review report</h1><p>Check totals before export.</p>");
  SpreadsheetApp.getUi().showModalDialog(output, "Report review");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

HtmlService.createHtmlOutputFromFile

Load a project HTML file for a sidebar or web application.

Parameters
filename: string without .html
Returns
HtmlOutput
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

HtmlOutput.getContent

Read the generated HTML source.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Returning the output object is essential; defining or constructing it without return produces undefined.
function main() {
  console.log(doGet().getContent());
}
function doGet() {
  return HtmlService.createHtmlOutput("<h1>Task workshop</h1><p>Ready to learn.</p>").setTitle("Task workshop");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

HtmlOutput.setTitle

Set the page title.

Parameters
title: string
Returns
HtmlOutput
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The new form contains a required text question and is separate from the existing Feedback form.
function main() {
  const form = FormApp.create("Workshop registration");
  form.addTextItem().setTitle("Name").setRequired(true);
  console.log(form.getId());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

ContentService.createTextOutput

Return textual web output such as JSON.

Parameters
content: string
Returns
TextOutput
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

TextOutput.setMimeType

Declare the returned content type explicitly.

Parameters
type: ContentService.MimeType
Returns
TextOutput
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

ScriptApp.newTrigger

Begin defining an installable trigger; setup does not execute its handler.

Parameters
functionName: string
Returns
TriggerBuilder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
A daily trigger definition is stored. The report handler is not executed by setup itself.
function main() {
  ScriptApp.newTrigger("dailyReport").timeBased().everyDays(1).atHour(9).create();
  console.log(ScriptApp.getProjectTriggers().length);
}
function dailyReport() { console.log("Daily report started"); }

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

ScriptApp.getProjectTriggers

Inspect triggers owned by the current user for this project.

Parameters
none
Returns
Trigger[]
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
A daily trigger definition is stored. The report handler is not executed by setup itself.
function main() {
  ScriptApp.newTrigger("dailyReport").timeBased().everyDays(1).atHour(9).create();
  console.log(ScriptApp.getProjectTriggers().length);
}
function dailyReport() { console.log("Daily report started"); }

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

ScriptApp.deleteTrigger

Delete the selected owned trigger after identifying it explicitly.

Parameters
trigger: Trigger
Returns
void
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

TriggerBuilder.forSpreadsheet

Choose a spreadsheet source before onEdit or onFormSubmit.

Parameters
id: string
Returns
SpreadsheetTriggerBuilder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The trigger targets spreadsheet edits, which provide a different event contract from form submissions.
function main() {
  const id = SpreadsheetApp.getActiveSpreadsheet().getId();
  ScriptApp.newTrigger("handleEdit").forSpreadsheet(id).onEdit().create();
}
function handleEdit(event) { console.log(event.range.getRow()); }

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

TriggerBuilder.forForm

Choose a Form source, whose submit event differs from a Sheet’s.

Parameters
id: string
Returns
FormTriggerBuilder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

TriggerBuilder.timeBased

Configure a scheduled trigger rather than an editor event.

Parameters
none
Returns
ClockTriggerBuilder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
A daily trigger definition is stored. The report handler is not executed by setup itself.
function main() {
  ScriptApp.newTrigger("dailyReport").timeBased().everyDays(1).atHour(9).create();
  console.log(ScriptApp.getProjectTriggers().length);
}
function dailyReport() { console.log("Daily report started"); }

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

PropertiesService.getScriptProperties

Read configuration shared by executions of this script.

Parameters
none
Returns
Properties
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The model name is configurable rather than silently pinned to a potentially retired model. No key is requested locally.
function main() {
  const settings = PropertiesService.getScriptProperties();
  settings.setProperty("GEMINI_MODEL", "SELECT_FROM_CURRENT_DOCS");
  console.log(settings.getProperty("GEMINI_MODEL"));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

PropertiesService.getUserProperties

Read user-scoped properties in Google; locally all scopes share one fictional store.

Parameters
none
Returns
Properties
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

PropertiesService.getDocumentProperties

Read document-scoped settings in supported contexts.

Parameters
none
Returns
Properties or null depending on context
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Properties.getProperty

Read a stored configuration string or explicitly handle its absence.

Parameters
key: string
Returns
string or null
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The model name is configurable rather than silently pinned to a potentially retired model. No key is requested locally.
function main() {
  const settings = PropertiesService.getScriptProperties();
  settings.setProperty("GEMINI_MODEL", "SELECT_FROM_CURRENT_DOCS");
  console.log(settings.getProperty("GEMINI_MODEL"));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Properties.setProperty

Persist a configuration value; sufficient project editors can access script settings.

Parameters
key: string, value: string
Returns
Properties
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The model name is configurable rather than silently pinned to a potentially retired model. No key is requested locally.
function main() {
  const settings = PropertiesService.getScriptProperties();
  settings.setProperty("GEMINI_MODEL", "SELECT_FROM_CURRENT_DOCS");
  console.log(settings.getProperty("GEMINI_MODEL"));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

CacheService.getScriptCache

Access an evictable temporary cache; always allow cache misses.

Parameters
none
Returns
Cache
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Configuration and cache retrieval are distinct; a missing cache key returns null and requires recomputation.
function main() {
  const settings = PropertiesService.getScriptProperties();
  settings.setProperty("REPORT_TAB", "Sales");
  const cache = CacheService.getScriptCache();
  cache.put("summary", "400", 60);
  console.log(settings.getProperty("REPORT_TAB"));
  console.log(cache.get("summary"));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Cache.get

Read a cached value if it has not expired or been evicted.

Parameters
key: string
Returns
string or null
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Configuration and cache retrieval are distinct; a missing cache key returns null and requires recomputation.
function main() {
  const settings = PropertiesService.getScriptProperties();
  settings.setProperty("REPORT_TAB", "Sales");
  const cache = CacheService.getScriptCache();
  cache.put("summary", "400", 60);
  console.log(settings.getProperty("REPORT_TAB"));
  console.log(cache.get("summary"));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Cache.put

Store a temporary string; expiry is not guaranteed durable storage.

Parameters
key: string, value: string, expirationInSeconds: number
Returns
void
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Configuration and cache retrieval are distinct; a missing cache key returns null and requires recomputation.
function main() {
  const settings = PropertiesService.getScriptProperties();
  settings.setProperty("REPORT_TAB", "Sales");
  const cache = CacheService.getScriptCache();
  cache.put("summary", "400", 60);
  console.log(settings.getProperty("REPORT_TAB"));
  console.log(cache.get("summary"));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

LockService.getScriptLock

Access a lock for cooperating script executions.

Parameters
none
Returns
Lock
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The lock is released in finally. The processing marker is written only after the intended cell write succeeds.
function main() {
  const lock = LockService.getScriptLock();
  if (!lock.tryLock(1000)) throw new Error("Another run is active");
  try {
    const settings = PropertiesService.getScriptProperties();
    if (settings.getProperty("processed:R1")) { console.log("Already processed"); return; }
    SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("B2").setValue("Complete");
    settings.setProperty("processed:R1", "yes");
    console.log("Processed R1");
  } finally { lock.releaseLock(); }
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Lock.tryLock

Attempt to acquire the lock; local contention is a configurable scenario.

Parameters
timeoutInMillis: nonnegative integer
Returns
boolean
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The lock is released in finally. The processing marker is written only after the intended cell write succeeds.
function main() {
  const lock = LockService.getScriptLock();
  if (!lock.tryLock(1000)) throw new Error("Another run is active");
  try {
    const settings = PropertiesService.getScriptProperties();
    if (settings.getProperty("processed:R1")) { console.log("Already processed"); return; }
    SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("B2").setValue("Complete");
    settings.setProperty("processed:R1", "yes");
    console.log("Processed R1");
  } finally { lock.releaseLock(); }
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Lock.releaseLock

Release a held lock in finally even if an operation failed.

Parameters
none
Returns
void
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The lock is released in finally. The processing marker is written only after the intended cell write succeeds.
function main() {
  const lock = LockService.getScriptLock();
  if (!lock.tryLock(1000)) throw new Error("Another run is active");
  try {
    const settings = PropertiesService.getScriptProperties();
    if (settings.getProperty("processed:R1")) { console.log("Already processed"); return; }
    SpreadsheetApp.getActiveSpreadsheet().getActiveSheet().getRange("B2").setValue("Complete");
    settings.setProperty("processed:R1", "yes");
    console.log("Processed R1");
  } finally { lock.releaseLock(); }
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

UrlFetchApp.fetch

Make an authorized server HTTP request; the local adapter returns authored fixtures only.

Parameters
url: string, params?: HTTP options object
Returns
HTTPResponse
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The documented method retrieves a local 200 fixture status; the plural method is invented.
function main() {
  const response = UrlFetchApp.fetch("https://example.com/fixture", {muteHttpExceptions: true});
  console.log(response.getResponseCode());
  console.log(response.getContentText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

HTTPResponse.getResponseCode

Read status before parsing the response body.

Parameters
none
Returns
integer
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The documented method retrieves a local 200 fixture status; the plural method is invented.
function main() {
  const response = UrlFetchApp.fetch("https://example.com/fixture", {muteHttpExceptions: true});
  console.log(response.getResponseCode());
  console.log(response.getContentText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

HTTPResponse.getContentText

Read response text, then parse and validate the expected schema.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The documented method retrieves a local 200 fixture status; the plural method is invented.
function main() {
  const response = UrlFetchApp.fetch("https://example.com/fixture", {muteHttpExceptions: true});
  console.log(response.getResponseCode());
  console.log(response.getContentText());
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Utilities.formatDate

Format a timestamp in an explicit zone; local support is UTC yyyy-MM-dd only.

Parameters
date: Date, timeZone: string, format: string
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
The timestamp identifies an instant; the supported UTC formatter extracts the same calendar date.
function main() {
  const date = new Date("2026-12-01T23:30:00Z");
  console.log(date.toISOString());
  console.log(Utilities.formatDate(date, "UTC", "yyyy-MM-dd"));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Utilities.sleep

Pause execution in Google; locally the delay is recorded without sleeping.

Parameters
milliseconds: nonnegative number
Returns
void
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Session.getScriptTimeZone

Read the project time zone, which may differ from a spreadsheet or user zone.

Parameters
none
Returns
string
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
getRange returns a Range object; setValue changes the selected cell. The name column stays unchanged.
function main() {
  const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
  sheet.getRange("B2").setValue("Complete");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

Logger.log

Write execution diagnostics without confusing a log with a returned value.

Parameters
data: value; optional formatting arguments
Returns
Logger
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
Calling the helper produces the second message. A helper definition alone produces no message.
function main() {
  console.log("Code.gs is ready");
  describeProject();
}
function describeProject() {
  console.log("Bound spreadsheet project");
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.

CardService.newCardBuilder

Build a structured Workspace add-on card; installing an add-on requires host-specific configuration.

Parameters
none
Returns
CardBuilder
Authorization
Google infers required scopes from used methods; inspect the consent request and this method’s Authorization section. Local adapters require no authorization.
Expected behavior
A card has a header and section with a text widget. The structural JSON is not an installed add-on.
function main() {
  const section = CardService.newCardSection().addWidget(CardService.newTextParagraph().setText("Review automation before applying changes."));
  const card = CardService.newCardBuilder().setHeader(CardService.newCardHeader().setTitle("Discovery toolkit")).addSection(section).build();
  console.log(JSON.stringify(card));
}

Run related lesson Official receiver reference

Related methods: inspect the same receiver’s other cards. Common mistake: calling a documented name on the wrong object or using an invalid argument shape.