eRROR:“您在短时间内一直在创建或删除太多日历或日历事件。”

问题描述 投票:0回答:0
第一次,“ Exportevents”功能正常工作。但是,一旦电子表格有更多的信息,它就没有完成脚本,而是说

“您在短时间内创建或删除了太多日历或日历事件。请稍后再试。” 这不是由于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); }
  • 脚本也有类似的问题,该脚本在工作日创建日历事件阻止,仅使用嵌套时环。我插入了实用程序。Sleep(3000),以便脚本每10次迭代后暂停。我对其进行了20周的测试,每周创建20个事件(400个事件),没有错误消息。我要处理这个时机,看看是否可以减少睡眠时间。这是Google开发人员参考信息:
  • https://developers.google.com/apps-script/reference/utilities/utilities#sleep(integer)

我有同样的错误,在Google上搜索让我在这里,所以我将留下解决方案。就我而言,我添加了电子邮件提醒,这导致“您在短时间内创建或删除了太多日历或日历事件。请稍后再试。”仅创建10秒事件后的错误。删除呼叫

Event.addEmailReminder()解决我的问题。

google-apps-script google-sheets google-calendar-api
最新问题
© www.soinside.com 2019 - 2025. All rights reserved.