I'm working on a Google Calendar addon that synchronizes event data with an external service. It's easy to get data like title, description, dates etc. of an event and I can even check wether it's a recurring event or not with event.isRecurringEvent()
.
What I can't seem to find out is how to get the recurrence rule(s) for a specific event. Is this even possible? Neither https://developers.google.com/apps-script/reference/calendar/calendar-event nor https://developers.google.com/apps-script/reference/calendar/calendar-event-series have something like getRecurrenceRule()
Thanks for any help!
If I understand you correctly, you have a CalendarEvent in Google Apps Script and you want to get its recurrence.
Since, as you said, there is not a method like getRecurrenceRule()
, you will have to activate the Advanced Calendar Service and call Events: get to get information on the recurrence of the event. If event
is your CalendarEvent
, you can retrieve the information on the recurrence by doing the following:
eventId = event.getId().split("@")[0];
var eventFromAPI = Calendar.Events.get(calId, eventId);
var recurrence = eventFromAPI["recurrence"];
return recurrence;
@
of the string returned by event.getId()
, because it appends @google.com
.recurrence
is a "list of RRULE, EXRULE, RDATE and EXDATE lines for a recurring event, as specified in RFC5545". Even though this has information of the recurrence of the event, it's not an instance of the Apps Script class RecurrenceRule. As far as I know, there is no way to return that.I hope this is of any help.