Showing toast when a button is clicked
Toast appears as a popup window in the lower-right corner of the active spreadsheet with a title and message. To create a toast dialog, edit or replace the greeting
function as follows:
function greeting() { SpreadsheetApp.getActiveSpreadsheet() .toast("Hello World!", "Greeting"); }
Now if you click the button, then a toast dialog will appear as shown in the following screenshot, and it disappears within 5 seconds (the default):
You can include a third argument, that is, timeout seconds, in the toast
method. This means how long the toast will be visible for. Put a negative number if you want it to show up forever. For example, toast("Hello World!", "Greeting", -1)
.
Tip
Toast only works in Sheets.