John Sosa-Trustham
John Sosa-Trustham

Reputation: 56

CalendarApp.getCalendarById returns null

We are using Google Apps Premier and I just noticed a change in behavior with the CalendarApp.getCalendarById() function, but it must have changed in the last month or so since it was working before the Christmas break.

The previous behavior (12/2012 and before) with the CalendarApp.getCalendarById() function used to be one where a calendar object was always returned as long as the calendar resource existed. Now this function returns null unless the the user has subscribed to the calendar resource. In the testing that I have done, as long as I am subscribed I get a calendar resource object and as soon as I unsubscribe, I start getting a null object. I have not tested with regular user calendars and have only tested with resources (such as rooms).

var calendar = CalendarApp.getCalendarById(calendarID);

This is pretty annoying since I need to run scripts against many rooms which I do not want to be subscribed to. The current work around of subscribing to a room or calendar is not very workable.

Upvotes: 3

Views: 3462

Answers (1)

Corey G
Corey G

Reputation: 7858

This has always been the case. You must have previously been subscribed and not realized it. I assure you this code was not changed.

Upvotes: 1

Related Questions