我一直使用相同的腳本將約會導入到日曆2年,沒有任何問題。今天突然間,我得到一個讀取TypeError的錯誤代碼:在對象Calendar中找不到函數createAllDayEvent。 (第35行,文件「代碼」)腳本嘗試將全天事件導入到日曆時的錯誤代碼
爲什麼會發生這種情況?我們使用這個腳本安排公司交付,所以我真的需要它的工作。任何幫助將不勝感激!!
這是我一直在使用腳本...
function importCalendar() {
var sheet = SpreadsheetApp.getActiveSheet();
var headerRows = 1; // Number of rows of header info (to skip)
var range = sheet.getDataRange();
var data = range.getValues();
var calId = "CALENDAR ID HERE";
var cal = CalendarApp.getCalendarById(calId);
for (i=0; i<data.length; i++) {
if (i < headerRows) continue; // Skip header row(s)
var row = data[i];
var startDate = row[3]; // Fourth column
var title = row[1]; // Second column
var location = row[2];
var description = row[4];
var id = row[6]; // Seventh column == eventId
var advancedArgs ={description: description, location: location};
// Check if event already exists, update it if it does
try {
var event = cal.getEventSeriesById(id);
}
catch (e) {
// do nothing - we just want to avoid the exception when event doesn't exist
}
if (!event) {
//cal.createEvent(title, new Date("March 3, 2010 08:00:00"), new Date("March 3, 2010 09:00:00"), {description:desc,location:loc});
var newEvent = cal.createAllDayEvent(title, new Date(startDate), advancedArgs).getId(); This is the row with the error.
row[6] = newEvent; // Update the data array with event ID
}
else {
Utilities.sleep(5000);
event.setTitle(title);
event.setDescription(description);
event.setLocation(location);
// event.setTime(tstart, tstop); // cannot setTime on eventSeries.
// ... but we CAN set recurrence!
var recurrence = CalendarApp.newRecurrence().addDailyRule().times(1);
event.setRecurrence(recurrence, new Date(startDate));
}
debugger;
}
// Record all event IDs to spreadsheet
range.setValues(data);
}
這實際上是一個谷歌的問題。它再次運作。謝謝您的幫助!! – Mary