2

I want to show progress of a lengthy script to the user. Ideally I want to use the yellow toast that comes up saying running script cancel dismiss when running a Google script

I know u can throw custom error but how can throw custom messages to this yellow box.

Or another alternative will do as well. Not msgbox as that stops the script.

mfaiz
  • 475
  • 1
  • 7
  • 17
  • See the following Stack Overflow answer: [Link to Stack Overflow answer](https://stackoverflow.com/a/24436445/2946873) – Alan Wells Jul 15 '17 at 20:08

2 Answers2

8

I ended up using the spreadsheet class of toast:

SpreadsheetApp.getActiveSpreadsheet().toast('message')

mfaiz
  • 475
  • 1
  • 7
  • 17
  • How is the toast closed? How does it know the long running script has completed? – aNewb Apr 01 '21 at 16:06
  • To know how long a running script has prolonged, you have to update the toast message with a variable count, like the following: .toast(`PROGRESS: Math.round(${count} / 7*100) `); or any other way like showing "7 out of 100" instead of percentages. Create a new thread if this still confuses you, but the above solution is correct. EDIT: use backticks (`) instead of quote marks to include ${} string interpolation syntax – lattejiu May 26 '21 at 06:44
0

I would think htmlService would work for you:

function function1() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var sheet = ss.getSheets()[0];

  var htmlApp = HtmlService
  .createHtmlOutput('Your Message')
     .setTitle("Progress")
     .setWidth(750)
     .setHeight(220);

 SpreadsheetApp.getActiveSpreadsheet().show(htmlApp);

}
OblongMedulla
  • 1,471
  • 9
  • 21
  • How would I update the creahtmloutput part during the code or would it have to be copying and pasting this code everytime – mfaiz Jul 14 '17 at 19:06
  • Thanks for your answer it opened door to a new area, coincedently i called my function toast and it just so happens there is a spreadsheet class called toast! Which practically does what I need it to do. Thanks a lot – mfaiz Jul 17 '17 at 09:15