.getStartTime() not a function?

拜拜、爱过 提交于 2019-12-25 04:39:19

问题


how do i get .getStartTime to work?
i'm using the CalendarEvent class, and .getStartTime is listed under this class (https://developers.google.com/apps-script/reference/calendar/calendar-event#getStartTime())
but when i try to run the following code, i get TypeError: Cannot find function getStartTime in object CalendarEvent.

function test() {
  var TA =CalendarApp.getCalendarsByName("CalendarName")[0].getEvents(startDt, endDt);
  var starting = TA.getStartTime();
  Logger.log(starting);
  return;
};

what am i doing wrong? i can't figure it out, all the tutorials i found online indicates that this should work.


回答1:


Looking at getEvents(Date,Date) it returns CalendarEvent[] .

So , you're trying to call a method on an entire array, instead of a particular CalendarEvent object.

Simply use TA[0].getStartTime() or whichever event you'd like.



来源:https://stackoverflow.com/questions/40489432/getstarttime-not-a-function

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!