Reputation: 49
I would like to retrieve Google Meet links on the calendar using Google App scripts. I understood that this requires the Advanced Calendar Service and have enabled it. I tried this from another thread. It works but I would like to specify a date range. How do I do that?
Upvotes: 1
Views: 2467
Reputation: 26836
timeMin
and timeMax
Thereby:
timeMax
: Upper bound for an event's start time
timeMin
: Lower bound for an event's end time
Those parameters are arguably not very user-friendly and it might be easier to use the method CalendarApp.getEvents(startTime, endTime) which returns events returns events that start and end during the specified time range.
Sample how to combine CalendarApp
with Advanced Calendar Service
:
function myFunction() {
var calendarId = "primary";
var now = new Date();
var twoHoursFromNow = new Date(now.getTime() + (2 * 60 * 60 * 1000));
var events = CalendarApp.getEvents(now, twoHoursFromNow);
if (events.length != 0){
for (var i = 0; i < events.length; i++){
var event = events[i];
var eventId = event.getId().split("@")[0];
Logger.log(eventId);
var eventSummary = event.getTitle()
var hangoutLink = Calendar.Events.get(calendarId, eventId).hangoutLink;
Logger.log (" Event: " + eventSummary + ", link: " + hangoutLink);
}
}
}
Upvotes: 1