Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

TypeError: calendar.getName is not a function

Why do I try to use getname(), the console gives me an error?

var cList = CalendarApp.getAllCalendars();
for (calendar in cList) {
  calendarList.push(calendar.getName());
}

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

Looks like there’s a bit of an issue using the for…in loop.

In the snippet shared, calendar is just an index (number) and accordingly, you could make use of something like this —

function myFunction() {
  var cList = CalendarApp.getAllCalendars();
  var calendarList = [];
  for (calendar in cList) {
    calendarList.push(cList[calendar].getName());
  }
  console.log(calendarList);
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading