Pages

Thursday, 25 July 2019

Search Google Calendar for event details

The following Google Apps Script is designed to search through a given date on Google Calendar, look through the events and then extract their Title & Id. The script is standalone so it only logs the output but you could copy it into a Google Sheet and write the data into the spreadsheet.

The 'CalendarApp' is used to perform the task and we start by getting hold of the relevant calendar.
var calendar = CalendarApp.getCalendarById(calendarId);
Next we get an array of the events for our given date.
var allEvents = calendar.getEventsForDay(date);
As we now have an array we need to loop through each returned event and extract the Title & Id.
for (var i=0; i<allEvents.length; i++) {
    var event = allEvents[i];
    var eventTitle = event.getTitle();
    var eventId = event.getId();
}

Search for events on date.gs

No comments:

Post a Comment