Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Google Apps Script and Trigger when new Calendar Event is added

I want to have a Goggle Apps Script be run when a new Calendar Event is added to a Google Calendar. How can I setup the trigger? I know what I want to script (change color for an event based on the text in the Title). I just don't see where to setup the trigger to run my script.

like image 988
user31673 Avatar asked Apr 05 '17 22:04

user31673


2 Answers

  1. Go to https://script.google.com/home/triggers (also available in your script editor, go to Edit -> All your triggers).
  2. Create or edit the trigger for your script.
  3. For event source use "From calendar", put "Calendar updated" to calendar details (see the image below) and specify the calendar owner email.

Trigger configuration

like image 135
Code Your Dream Avatar answered Sep 19 '22 00:09

Code Your Dream


You can use the new Google Calendar Event Triggers. You can create the code with a script similar to the following to trigger your function:


     ScriptApp
      .newTrigger('findNewEvents')
      .forUserCalendar(Session.getActiveUser().getEmail())
      .onEventUpdated()
      .create()
  

Then you can loop through the events in your calendar to find any events recently created and pass them to your function.

like image 35
webstermath Avatar answered Sep 19 '22 00:09

webstermath