Tri Nguyen
Tri Nguyen

Reputation: 11108

Get all calendars in Google Apps Scripts CalendarApp class

So Google Apps Scripts allow you to getCalendarByID, getCalendarsByName and getDefaultCalendar, which works great when you need to target a specific calendar. However, I was wondering if there's a way for me to get ALL the Calendars that is associated with the account?

I've tried getCalendarsByName(), getCalendarsByName('') and getCalendarsByName('*'), none of which works.

Upvotes: 0

Views: 2881

Answers (2)

Clark Lind
Clark Lind

Reputation: 57

This works for me:

function get_calendars() {
var calendars = CalendarApp.getAllCalendars();
for (var i = 0; i < calendars.length; i++) {
var calendar = calendars[i];
Logger.log(calendar.getName());
}
}

Upvotes: 2

Serge insas
Serge insas

Reputation: 46802

have you tried getAllCalendars() ? Get all Calendars subscribed to by this user

Upvotes: 5

Related Questions