This post was originally published at https://aira.net/blog/using-apps-script-to-encourage-our-team-to-take-time-off/ and is canonicalised to that page.
Recently, Paddy wrote a post about Aira’s Unlimited Holiday policy, and how we make sure it’s delivering everything we want it to for the Aira team. Most importantly, how we make sure that it doesn’t result in people taking less leave than they would otherwise. That might sound strange, but other companies have fallen into that trap.
One of the ways we do that is with some simple tech. Simple reminders which help Team Leads to report on leave in various formats, and to get alerts if someone hasn’t booked enough leave over the next three months.
This post is about using Apps Script to create an information API for pretty much any leave platform.
Here’s the problem – many leave platforms don’t have an API
While there’s lots of great tools out there to manage HR and leave, with useful features for keeping on top of things, many of them don’t offer an API.
That could mean we’re restricted to whatever reporting/alerting features the platform has built in.
Most leave platforms let you subscribe to the “leave calendar”
We happen to use CharlieHR, but most of them work the same. You go into the tool, get a “calendar subscribe” link and chuck it into Google Calendar.
That way you’re able to see all the holidays people have coming up within your Google Calendar.
If it’s in a Google Account – Apps Script can read it
I’m not going to go on too much about Apps Script, but it’s great. It lets you automate all sorts of things within, or between, different Google Workspace programs.
There’s a bunch of things that come baked in to Apps Script. For example, we can use:
CalendarApp.getAllCalendars();
to get a list of every calendar an account has access to.
And we can use:
calendar.getEvents(startDate, endDate);
to get a list of every event in a calendar that takes place between two dates. Once we’ve got that information, we can check the event titles to see who has leave coming up and compare that list to a list of people working for the company.
If anyone doesn’t have any leave booked over the next 90 days or so, we automatically send an email to them, and their line manager, reminding them that it’s a good idea to book some time off, using code like this;
MailApp.sendEmail(
targetAddress,
subjectToSend,
emailBody, {
htmlBody: emailBody
})
A video to walk you through using Apps Script with Google Calendar
The most important thing is giving people the tools for success
There are loads of things that could distract someone from booking leave. While this isn’t the most complex thing we’ve built at Aira, it’s really important to us that we invest in little projects like this. After all, what’s the point of having machines if they can’t help us be more human?