Last active
April 7, 2018 18:28
-
-
Save rudimusmaximus/78712a40c02ca3dc9536e351198a9fa8 to your computer and use it in GitHub Desktop.
In Google Apps script (for a sheet), use "bookend toast" messages to cleanly communicate with user when script has executed first and last line
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* Example use of a single pair of toast messages | |
*/ | |
function doSomethingExample() { | |
//toast(msg, title, timeoutSeconds) | |
SpreadsheetApp.getActive().toast("Working...", "Doing x", 30);//message 1 longer than you need | |
Utilities.sleep(8000); //8 seconds simulating work | |
SpreadsheetApp.getActive().toast("Finished!","OK", 2);//message 2 interrupts message 1 | |
return true; | |
}//end doSomethingExample() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Because of the way toast works (one message at a time, new messages interrupt and overwrite previous ones), I think this approach works well but is not likely useful to have multiple messages within the function other than start and stop.
This approach works if you know you can set more time than you need and you change the title only and keep it simple to provide context. This way the user isn't trying to overly focus on the toast messages.
Design another way to show more granular progress or status of your function if needed.
This at least keeps the user informed at the highest level.