google-apps-scriptmsgbox

How to create a Message-Box in Google Apps Script


I am creating an new Google Apps Script about GDrive/New/More/Google Apps Script.

enter image description here

The script is running perfect and on the end my intention is to send a Info on the Desk.

When I am using this line:

Browser.msgBox("TEST");

I get the error back:

Exception: Cannot call Browser.msgBox() from this context; have you tried Logger.log() instead?

Logger.log can't be the solution, because I don't see the result on the desktop, but only in the log files.

Is there another solution or is it possible to get a simply example what I can do?


Solution

  • In this case Browser.msgBox is a method for the Browser class, this class is specifically meant to be used in Spreadsheets as stated in the documentation:

    Class Browser This class provides access to dialog boxes specific to Google Sheets.

    The methods in this class are only available for use in the context of a Google Spreadsheet.

    If you want a notification you could use either the Browser.msgBox method or the Toast method, either way they both need to be applied in a Spreadsheet in order to work.