Shows a simple alert box with an OK button.
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
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.
More Apps Script
3 Better Sheets tutorials
Add Columns Automatically
Automate Emails
Related blog posts
Written guides about SpreadsheetApp.alert().
Can I get alerted when a tab name is changed?
Use Apps Script to receive emails whenever there’s a change in your Google Sheet structure Are you an organization with multiple people working on the same Google Sheets file? Then, you might want to know when one of your people changes something in the spreadsheet, whether that be adding or deleting columns, changing the format, or adding tabs. In particular, one of our community members recently asked, “Can I get alerted when a tab name is changed?” To be honest, I didn’t know the answer...
Read post →What's Better Than Google Sheets?
Nothing is better than Google Sheets. You just need to learn more about the unlimited power of Google Sheets. Functions, Formulas, Apps Script and more.
Read post →Google Sheets AI Formula
Does Google Sheets have an AI Formula? No but you can add one. Simple use Apps Script to add an AI formula to your sheets. You can use your own AI from Open AI and this comes out to be much cheaper than even $20 a month for ChatGPT at times. Depends on your use of AI. I just updated Better Sheets' AI apps script to use Open AI Omni. Get the full script here. Can I use ChatGPT in Google Sheets? No but you can create ChatGPT in Google Sheets. Let me show you! But I need help with Google...
Read post →