Google Apps Script toast messages don’t appear for anonymous editors

  • You want to display a message when the cells of Spreadsheet are edited by anonymous.
  • The Spreadsheet is publicly shared for anonymous users as the editor.

If my understanding is correct, how about this answer? Unfortunately, even when the installed OnEdit event trigger is used, when anonymous users are edited, toast() and Class Ui cannot be used. So as one of several workaround, I would like to propose to use the images. Fortunately, insertImage() can be used for this situation. So I’m using this workaround. Please think of this as just one of several answers.

Before you use this script, please prepare an image for displaying.

Sample script:

Before you use this script, please set the file ID of the image. And please install the OnEdit event trigger for the function of showMessage().

function showMessage(e) {
  var fileId = "###"; // Please set the file ID of the image.

  var sheet = e.source.getActiveSheet();
  var blob = DriveApp.getFileById(fileId).getBlob();
  var image = sheet.insertImage(blob, 2, 3);
  Utilities.sleep(3000);
  image.remove();
}
  • In this sample script, when the cell is edited, the prepared image is displayed and waited for 3 seconds, and then, the image is removed.

Result:

enter image description here

Note:

  • Of course, you can create an image for displaying with the script. But in this case, the process cost will become high. As the result, the time until the image is displayed becomes long. So I proposed to use the image which was created in advance.

References:

  • toast()
  • Class Ui
  • Installable Triggers
  • insertImage()

If I misunderstood your question and this was not the direction you want, I apologize.

Leave a Comment