Apps Script Google Calendar: Getting Invalid Event ID Error When Working with Repeating Events

Hi everyone, I need some help with a Google Apps Script project that’s giving me headaches.

What I’m trying to do:
I built a script that checks our company’s meeting room calendars every day. It looks for bookings scheduled for tomorrow and sends emails to the people who booked them. The emails have links so they can either confirm they still need the room or cancel if they don’t.

The problem:
Everything works fine for regular one-time events, but I keep getting “Invalid Event ID” errors when dealing with repeating events. It seems like the event IDs for recurring meetings are tricky to handle.

My current approach:
I’m trying to create unique IDs for each instance of a recurring event like this:

let uniqueEventId;
if (calendarEvent.isRecurringEvent() && !originalId.includes("_R")) {
    uniqueEventId = `${originalId}_${formattedDateTime}@google.com`;
} else if (originalId.includes("_R")) {
    uniqueEventId = `${originalId.split("_R")[0]}_${formattedDateTime}@google.com`;
}

This works most of the time, but sometimes it still breaks. I think it happens when someone has modified a single instance of a recurring event or deleted one occurrence.

What I need help with:

  • How do you properly handle event IDs for recurring events in Apps Script?
  • Are there any reliable ways to avoid these invalid ID errors?
  • Any tips for dealing with modified instances of recurring events?

Thanks in advance for any help you can provide!