Automatically creates and deletes 15min appointments around changed Google Calendar events to allow for leeway
The trigger script searches for changed Calendar appointments and determines which were added and removed. Next, blockers are added before and after the added events and removed from the removed events (unless the blocker is adjacent to another appointment, in which case it is kept).
A syncToken is kept in a separate sheet to keep track of the Calendar state and allow for incremental updates.
- Create required files
- Create a new project at https://script.google.com/
- Create a new Google Sheet (to save calendar state) and note the hash ID (from the hyperlink)
- Update the script
- Activate the
Google Calendar API
Service under the Services menu (From the left menu in the Editor) - Copy the script from the
Code.gs
file to your open script - Enter the hash ID previously noted in this script as VARIABLES_SHEET_ID (quoted)
- Activate the
- Set up the script functionality
- Run the resetToken() function by selecting it from the dropdown menu and clicking
run
to write the intial syncToken to above mentioned sheet. - Create a
Calendar Upated
trigger forwhenUpdated()
from the Triggers menu
- Run the resetToken() function by selecting it from the dropdown menu and clicking