Making a pop-up/pop-down alert on G sheeets

152 views
Skip to first unread message

rob wilson

unread,
Dec 11, 2023, 3:39:58 PM12/11/23
to Google Apps Script Community
I have an onOpen function that can take quite a while to complete. I want to stop the user doing any edits at all until the function has been completed, and ideally the user should get a "Working, please wait" message, 
I've looked at some docs and discussions, but the problem seems to be that the ui.alert() and similar functions actually suspend processing until the user clicks a button (for example).
Any ideas?

Keith Andersen

unread,
Dec 11, 2023, 4:12:20 PM12/11/23
to google-apps-sc...@googlegroups.com
Have you looked at the lock service? A script or document lock?

Try a toast message. The script posts the toast message and then continues on. So you could have a message saying this script will be temporarily locked for x seconds while it finishes processing. Then set the toast time for that amount of time..

Keith 

--
You received this message because you are subscribed to the Google Groups "Google Apps Script Community" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-apps-script-c...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/google-apps-script-community/6be4e780-0108-434d-8626-5d51b3f423bbn%40googlegroups.com.

Keith Andersen

unread,
Dec 11, 2023, 6:04:09 PM12/11/23
to google-apps-sc...@googlegroups.com
Or ....
Make a regular pop-up and upon them answering, the calculations begin or you could simply use continue so that the script continues along.

A couple options anyway

George Ghanem

unread,
Dec 13, 2023, 2:47:18 PM12/13/23
to google-apps-sc...@googlegroups.com
You should look at speeding up your script. Unless it is doing massive update on the sheet.

One suggestion may be to change access privileges of other users until changes are complete..


--

Keith Andersen

unread,
Dec 13, 2023, 2:59:45 PM12/13/23
to google-apps-sc...@googlegroups.com
George,
I'm not too experienced here, but wouldn't lock service lock either the document or script from user interference better / easier than redefining user privileges?

Keith 

George Ghanem

unread,
Dec 14, 2023, 12:36:15 AM12/14/23
to google-apps-sc...@googlegroups.com
Lock service will only prevent the script from running, the spreadsheet will still update. I took his question as in wanting to prevent spreadsheet from changing until script completed.

Andrew Roberts

unread,
Dec 15, 2023, 6:15:01 AM12/15/23
to google-apps-sc...@googlegroups.com

Keith Andersen

unread,
Dec 15, 2023, 11:15:23 AM12/15/23
to Google Apps Script Community
Thanks George. I'm going to do some experimenting. I'd like to see if the lock document would do the trick.
Cheers

rob wilson

unread,
Dec 16, 2023, 12:17:27 PM12/16/23
to Google Apps Script Community
The Sheets extension "Crop sheet" does a great job - see screenshot. Just what I'm looking for!
Screenshot 2023-12-16 17.07.41.png
The code is public on github. But I can't see anything in the code that does this, so I guess that it's a built-in function for extensions?
Rob
Reply all
Reply to author
Forward
0 new messages