Coding level: Beginner
Duration: 15 min
Project type: Automation with a time-based trigger
About this solution
A shared vacation calendar is a great tool for helping your team collaborate; anyone can determine who's out of the office at a glance. This solution lets you see when your colleagues are out of the office, with no manual entry required.
How it works
This solution populates a shared vacation calendar based on the individual calendars of each person in a Google Group. When someone books time off, they add an event to their personal Google Calendar using a keyword like "Vacation" or "Out of office."
Every hour, the script scans the calendars of the members in a Google Group and syncs appropriate events to the shared calendar. You can change how often the script scans for new events.
Apps Script services
This solution uses the following services:
- Groups Service: Determines the members of the Google Group.
- Advanced Calendar Service: Provides access to the Calendar API and searches for events on the group members' calendars.
Before you begin
To use this sample, you need the following prerequisites:
- A Google Account (Google Workspace accounts might require administrator approval)
- A web browser with access to the internet
Step 1: Set up Google Calendar
- Open Google Calendar.
- Create a new calendar called "Team Vacations."
- In the calendar's settings, under Integrate calendar, copy the Calendar ID.
Step 2: Make a copy of the sample script
- Click the button below to open the Vacation Calendar Apps Script project.
Open the project
- Click Overview .
- At the top-right, click Make a copy .
- Set the variable
TEAM_CALENDAR_IDto the ID of the calendar you created earlier.
- Set the variable
GROUP_EMAILto the email address of a Google Group containing your team members.
- At the left, next to Services, click Add a service .
- Select Google Calendar API and click Add.
Step 3: Populate the calendar
- In the function dropdown, select setup.
- Click Run.
- When prompted, authorize the script.
- When complete, return to Google Calendar to confirm the Team Vacations calendar is populated with events.
You can edit the team vacation calendar automation as much as you'd like to fit your needs. Below is an optional change to modify the trigger.
Change how often the script scans for new events
To change how often the script runs, take the following steps:
- In the Apps Script project, click Triggers .
- Next to the trigger, click Edit Trigger .
- Select your changes and click Save.
This sample is maintained by Google with the help of Google Developer Experts.