Installing from the marketplace - automatically creating a time trigger

23 views
Skip to first unread message

Jake Green

unread,
Jul 20, 2021, 10:07:00 AM7/20/21
to Google Apps Script Community
Hello.
My app runs in the background without user interaction - it syncs sheets - tasks - calendar.
But I need to ensure that when installing from the marketplace, a time trigger is created to automatically launch the application (functions of subroutines) on a schedule once a day.

Can anyone give me an idea for marketplace installation and triggers? I would be very grateful.

Clay Smith

unread,
Jul 20, 2021, 10:52:10 AM7/20/21
to google-apps-sc...@googlegroups.com
Hi Jake, 

The onInstall function used by the marketplace is considered a simple trigger. Simple triggers are able to run functions which do not require authentication. The onInstall is run without authentication since it occurs before user interaction. We'd have a whole host of security issues if installing an AddOn kicked off a process. 

Best practice is to hook your function to a menu. The user will select the menu item which installs the timed trigger. On selecting AppScript will prompt for the initial authorization it needs to proceed. Be sure to include a menu option to stop your timed trigger as well. 

Hope this helps. 

Clay


--
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/d0497e34-7a2d-4b20-8460-2f1ac86beb3dn%40googlegroups.com.


--


Jake Green

unread,
Jul 20, 2021, 11:22:37 AM7/20/21
to Google Apps Script Community
Clay, Thank You for your prompt and helpful reply.
Yes, this is a really rational way. My desire to move the user away from participation is not entirely correct in terms of transparency and control over background processes. The user must have control and knowledge of the processes in his space and the ability to disable the schedule.
Thank You so much. I will apply this.

вторник, 20 июля 2021 г. в 17:52:10 UTC+3, Clay Smith:
Reply all
Reply to author
Forward
0 new messages