G Suite Group Calendar Automation
As you may know, G Suite provides the ability to create shared group calendars, which are great for 1:many sharing.
Many teams would like to have visibility not only into a shared administrative calendar, but also their team-mates’ calendars; while you can do this by adding your team members in your calendar left-nav, it’s a chunk of manual clicking every time, particularly if you have a large team.
A shared team calendar would seem to be the trick; however, many users (me included) don’t want to copy their appointments from their main calendar to a shared calendar; it’s just too much overhead.
Fortunately, this can be automated with Apps Script:
- Google Groups provides a simple way to manage and access your team list; note that to be able to access it programmatically, this must be a domain-managed group.
- The Calendar API provides the ability to copy appointments between calendars (with a bit of work: there isn’t a native copy function), and to invite group calendars to a user’s calendar.
Shared calendar approaches
There are two fundamental approaches here, each with their pros and cons.
Copy each users events to the shared calendar:
- This only requires view permissions on the user’s calendar
- Changes to the user’s calendar are only reflected on the shared calendar when the next refresh is run.
- The script needs to add meta-data to the calendar event to update/remove events on refresh since the event ids in the shared calendar are different than the event ids in the user’s calendar.
- It’s a chunk of code to get and set all the event attributes since there isn’t a copy method.
Invite the shared calendar to the user’s calendar
- This requires elevated, ie. edit, privileges on the user’s calendar
- Changes to the user’s calendar are reflected immediately in the shared calendar.
- The user’s events will have an additional group calendar invitee, which can look a little obscure.
The following script takes the second approach; it only includes events to which a particular domain have been invited, so you can have separate shared calendars for different clients with whom you work, for instance.