Been using CalendarApp
to help aggregate multiple Google calendars from different accounts into a single formatted spreadsheet which has been working beautifully. However, we want to incorporate more than just these calendars into the system and have been having trouble retrieving data from an imported calendar that we are subscribed to.
This calendar is from Trello (uses a power-up to create a calendar based on due dates) which provides a URL for us to subscribe to on Google. When I attempt to use the same CalendarApp.getCalendarById(calendarId)
, it doesn't appear to be able to access the event data and returns null
.
For reference, here is the calendar id: mp9si8iqi6uop4a20pr0r1v000dc9pcu@import.calendar.google.com. The format is slightly different from Google calendars ending in @group.calendar.google.com.
Are we able to access calendar information from imported calendars like these? I tried .getCalendarsByName(calendarName)
as well with no luck, but is there another way to view this data and include it in our calendar spreadsheet? Any help is appreciated!
If I was unclear, I tried the following:
calendarId = "mp9si8iqi6uop4a20pr0r1v000dc9pcu@import.calendar.google.com";
CalendarApp.getCalendarById(calendarId);
//and
calendarName = "Collab, Events & Special Buy";
CalendarApp.getCalendarsByName(calendarName);
Only an issue with this calendar which is managed by Trello
You can definitely get information from imported calendars. Please try using the following code:
function myFunction() {
var calendarId = "YOUR_CALENDAR_ID";
var cal = CalendarApp.getCalendarById(calendarId);
Logger.log(cal.getName());
Logger.log(cal.getDescription());
Logger.log(cal.getTimeZone());
Logger.log(cal.getColor());
}
Run it, and navigate to View>Logs. You should be able to see the calendar's information. I recommend you also try the following:
List all your calendars and find the one you desire. You should be able to find it, and also extract its id. https://developers.google.com/calendar/v3/reference/calendarList/list
List the events on your calendar. You only have to set the calendarId
value that you have just retrieved and execute it. You should be able to see the events on your calendar. https://developers.google.com/calendar/v3/reference/events/list