“您在短时间内创建或删除了太多日历或日历事件。请稍后再试。” 这不是由于Google设置的每日配额所致,因为我每天没有创建接近10,000个活动。我搜索了一个解决方案,并在 @jevans-gsa的Google Product论坛上找到了这一点,他将脚本基于 @mogsdad的脚本。 i我调整了他的解决方案,并将“ UpdateEvents”函数与“ ExportEvents”(并创建了“ DeleteeVents”函数)分开。现在,“ ExportEvents”不会遇到“您在短时间内创建或删除过多的日历或日历事件。请稍后再试”问题。
但是“更新”仍然会得到相同的警告,在执行中一半!,例如,我创建了83个名为“ 1”到“ 83”的事件,并导出了 成功日历的事件。
然后我将活动标题更改为“ 100”为“ 182”,并试图更新事件。 仅更新为“ 101”〜“ 114”的“ 1”〜“ 15”,其他所有内容保持不变。 - 我使功能更新为“状态”列,为“更新(今天的) 日期)”,也没有执行。
因此,该功能开始但没有完成,这使我认为错误必须在设置复发中的某个位置。是否有解决方法可以使“更新”起作用,或者是原始答案中建议的@@mogsdad,是删除和重新创建事件的唯一其他方法? to我的电子表格-https://docs.google.com/spreadsheets/d/1v6eioco4qdpo2ddcyw93slrrwt_xtzkm-drdpvi1gd8s/edit? 和我当前的脚本:
//Global settings
var calId = '[email protected]';
var moderatorEmail = 'EMAIL_ADDRESS';
var idId = 0;
var startTimeId = 1;
var endTimeId = 2;
var titleId = 3;
var organizerId = 4;
var locId = 5;
var descId = 6;
var urlId = 7;
var topicId = 8;
var typeId = 9;
var contactId = 10;
var contactEmailId = 11;
var actionId = 12;
var statusId = 13;
//Add a custom menu
function onOpen() {
var ss = SpreadsheetApp.getActive();
var items = [
{name: 'Export Events', functionName: 'exportEvents'},
{name: 'Update Events', functionName: 'updateEvents'},
{name: 'Delete Events', functionName: 'deleteEvents'}
];
ss.addMenu('Calendar', items);
}
//Actual functions
function exportEvents() {
var spreadsheet = SpreadsheetApp.getActiveSheet();
var headerRows = 2; //Number of rows of header info to skip
var range = spreadsheet.getDataRange();
var data = range.getValues();
var cal = CalendarApp.getCalendarById(calId);
for (i in data) {
if (i < headerRows) continue; //Skip header rows
var row = data[i];
var title = row[titleId];
var tstart = new Date(row[startTimeId]);
tstart.setDate(tstart.getDate());
tstart.setMonth(tstart.getMonth());
tstart.setYear(tstart.getYear());
tstart.setTime(tstart.getTime());
var tstop = new Date(row[endTimeId]);
tstop.setDate(tstop.getDate());
tstop.setMonth(tstop.getMonth());
tstop.setYear(tstop.getYear());
tstop.setTime(tstart.getTime());
var loc = row[locId];
var contact = row[contactId];
var organizer = row[organizerId];
var topic = row[topicId];
var type = row[typeId];
var contactEmail = row[contactEmailId];
var url = row[urlId];
var status = row[statusId];
var desc = (row[descId]
+"\n\n-Organizer: "+organizer
+"\n-Event URL: "+url
+"\n-Event Type: "+type
+"\n-Event Contact: "+contact+" ("+contactEmail+")")
var id = row[idId];
// Check if the 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("Month D, YYYY 00:00:00"), new Date("Month D, YYYY 00:00:00), {description:desc,location:loc});
var newEvent = cal.createEvent(title, tstart, tstop, {description:desc,location:loc}).getId();
row[idId] = newEvent; // Update the data array with event ID
var d = new Date();
var time = d.getMonth()+1 + "/" + d.getDate() + "/" + d.getFullYear()
row[statusId] = "Exported " + time
}
debugger;
}
range.setValues(data);
}
function updateEvents() {
var sheet = SpreadsheetApp.getActiveSheet();
var headerRows = 2; //Number of rows to skip
var range = sheet.getDataRange();
var data = range.getValues();
var cal = CalendarApp.getCalendarById(calId);
for (i in data) {
if (i < headerRows) continue;
var row = data[i];
var title = row[titleId]; //Second column
var tstart = new Date(row[startTimeId]);
tstart.setDate(tstart.getDate());
tstart.setMonth(tstart.getMonth());
tstart.setYear(tstart.getYear());
tstart.setTime(tstart.getTime());
var tstop = new Date(row[endTimeId]);
tstop.setDate(tstop.getDate());
tstop.setMonth(tstop.getMonth());
tstop.setYear(tstop.getYear());
tstop.setTime(tstart.getTime());
var loc = row[locId];
var contact = row[contactId];
var organizer = row[organizerId];
var topic = row[topicId];
var type = row[typeId];
var contactEmail = row[contactEmailId];
var url = row[urlId];
var action = row[actionId];
var status = row[statusId];
var desc = (row[descId]
+"\n\n-Organizer: "+organizer
+"\n-Event URL: "+url
+"\n-Type: "+type
+"\n-Event Contact: "+contact+" ("+contactEmail+")")
var id = row[idId];
try {
var event = cal.getEventSeriesById(id);
}
catch (e) {
// do nothing
}
if (event) {
if (action === "Update") {
event.setTitle(title);
event.setDescription(desc);
event.setLocation(loc);
// eventSetTime(tstart, tstop); // cannot setTime on eventSeries.
// ... but we Can set recurrence!
var recurrence = CalendarApp.newRecurrence().addDailyRule().times(1);
event.setRecurrence(recurrence, tstart, tstop);
var d = new Date();
var time = d.getMonth()+1 + "/" + d.getDate() + "/" + d.getFullYear()
row[statusId] = "Updated " + time
}
}
}
debugger;
range.setValues(data);
}
function deleteEvents() {
var sheet = SpreadsheetApp.getActiveSheet();
var headerRows = 2; //Number of rows to skip
var range = sheet.getDataRange();
var data = range.getValues();
var cal = CalendarApp.getCalendarById(calId);
for (i in data) {
if (i < headerRows) continue;
var row = data[i];
var action = row[actionId];
var status = row[statusId];
var id = row[idId];
try {
var event = cal.getEventSeriesById(id);
}
catch (e) {
}
if (event) {
if (action === "Delete") {
event.deleteEventSeries();
var d = new Date();
var time = d.getMonth()+1 + "/" + d.getDate() + "/" + d.getFullYear()
row[idId] = "Deleted";
row[statusId] = "Deleted " + time;
}
}
}
debugger;
range.setValues(data);
}
Event.addEmailReminder()
解决我的问题。