class SpreadsheetApp method .alert()

SpreadsheetApp is the Apps Script service.

.alert() is the method name you will see after a dot in your code.

What it does

Shows a simple alert box with an OK button.

Why it's used

  • Tell the user something went wrong in plain language.
  • Confirm a count like updated 12 rows.

Common errors

  • Forgetting parentheses on alert. Write SpreadsheetApp.alert(), not SpreadsheetApp.alert or alert by itself.
  • Skipping dots between chained calls. Each step needs a dot, like SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Data').alert().
  • Adding spaces where they do not belong. Write SpreadsheetApp.alert(), not SpreadsheetApp .alert(), SpreadsheetApp.alert (), or SpreadsheetApp . alert().
  • Wrong capitalization. Use SpreadsheetApp and alert, not spreadsheetapp or alert.

2 Snippets using this methods

Explore

Related methods

  • .prompt()

    Shows a dialog that asks the user for text input.

  • .toast()

    Shows a short message in the bottom corner of the spreadsheet.

  • .showModalDialog()

    Opens a modal dialog that blocks interaction with the sheet.

  • .showModelessDialog()

    Opens a dialog the user can use while still working in the sheet.

  • .addItem()

    Adds a menu item that runs a function when clicked.

3 Better Sheets tutorials

Add Columns Automatically

Add Columns Automatically

Create your own "Add Columns" button just like the add rows to the bottom.
Automate Emails

Automate Emails

Set up automated email notifications based on Google Sheets data. Super ...
Automatic Calculations

Automatic Calculations

Create custom scripts to make your spreadsheets more like tools.

Related blog posts

Written guides about SpreadsheetApp.alert().

Browse the blog