Google apps script &引用;CalendarApp:不匹配:etags“;添加提醒时-谷歌应用程序脚本
我有一个小的GoogleApps脚本,可以处理电子表格中的日期列,并在日历中生成条目(生日) 工作正常,但向(最近创建的)CalendarEvent添加提醒时,会引发错误: 服务错误:CalendarApp:不匹配:etags=[“GUQKRgBAfip7JGA6WhJb”],版本=[63489901413] 我尝试在创建事件后执行1秒睡眠(等待日历中的更改),但没有成功 顺便说一句,事件创建成功,只能添加提醒 PD:日历是我自己的,但不是我的主日历 以下是代码的一部分:Google apps script &引用;CalendarApp:不匹配:etags“;添加提醒时-谷歌应用程序脚本,google-apps-script,etag,Google Apps Script,Etag,我有一个小的GoogleApps脚本,可以处理电子表格中的日期列,并在日历中生成条目(生日) 工作正常,但向(最近创建的)CalendarEvent添加提醒时,会引发错误: 服务错误:CalendarApp:不匹配:etags=[“GUQKRgBAfip7JGA6WhJb”],版本=[63489901413] 我尝试在创建事件后执行1秒睡眠(等待日历中的更改),但没有成功 顺便说一句,事件创建成功,只能添加提醒 PD:日历是我自己的,但不是我的主日历 以下是代码的一部分: try {
try
{
birthday = new Date(Data[i][BirthColumn]);
birthday.setFullYear(today.getFullYear());
birthday.setUTCHours(12);
birthlist += Data[i][NameColumn] + " --> " + birthday + "\n";
calendarevent = cal.createAllDayEventSeries("¡Cumpleaños " + Data[i][NameColumn] + "!", birthday, CalendarApp.newRecurrence().addYearlyRule().times(YearsInAdvance));
if (calendarevent == null)
success = false;
else
{
//This sentence fails every single time.
calendarevent.addEmailReminder(0);
calendarevent.addPopupReminder(0);
calendarevent.addSmsReminder(0);
}
}
catch (ee)
{
var row = i + 1;
success = false;
errlist += "Error on row " + row + ": check name and birth date. Exception Error: " + ee.message + "\n";
}
这是一个
请参阅注释nr 67以了解解决方法:技巧是在使用cal.getEventSeriesById(eventID)
获得Id后,使用cal.getId()重新调用每个要添加的项目(提醒、弹出…)的事件
我在一些脚本中使用了它,它为我解决了这个问题。这是我最后更改的代码部分,以使其工作,正如Serge insas之前建议我的那样:
if (calendarevent == null)
success = false;
else
{
cal.getEventSeriesById(calendarevent.getId()).addEmailReminder(0);
cal.getEventSeriesById(calendarevent.getId()).addPopupReminder(0);
cal.getEventSeriesById(calendarevent.getId()).addSmsReminder(0);
}
谢谢Serge,这解决了我的问题。我以前读过这个问题,但它是在2010年第一次发布的,我认为这是一个解决了的问题。。。再次非常感谢你。这确实是一个“旧的”。。。不知道为什么这么难解决;-/幸运的是,这个解决方法还可以,虽然有点慢。感谢您提供了一个代码示例,我也应该考虑一下;-)