Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Google apps script google日历无法按id删除事件_Google Apps Script_Google Calendar Api - Fatal编程技术网

Google apps script google日历无法按id删除事件

Google apps script google日历无法按id删除事件,google-apps-script,google-calendar-api,Google Apps Script,Google Calendar Api,因此,我有一个应用程序脚本代码,可以创建如下事件: var cal = CalendarApp.getCalendarById(calendarId); var start = new Date(startDt); var end = new Date(endDt); var event = cal.createEvent(title, start, end, { description : desc, }); 它运行良好,在创建事件后,我使用 event.getId() 记录事件

因此,我有一个应用程序脚本代码,可以创建如下事件:

var cal = CalendarApp.getCalendarById(calendarId);
var start = new Date(startDt);
var end = new Date(endDt); 
var event = cal.createEvent(title, start, end, {
 description : desc,
});   
它运行良好,在创建事件后,我使用

event.getId()
记录事件id的步骤

当我运行以下代码以使用我记录的id删除事件时,它告诉我该事件不存在

var cal = CalendarApp.getCalendarById(calendarId);
var event = cal.getEventSeriesById(evc2);
event.deleteEventSeries();
return;
为什么找不到事件
我用来记录事件id的代码是否不正确?

还是我试图删除事件的方式不正确?

因此,当我单独运行代码时,代码可以工作,所以问题出在其他地方。
在完成一些清理和删除未使用的变量后,它再次开始工作。我不知道问题出在哪里,但它现在正在工作,感谢您的输入

我查看了文档,您的代码似乎应该可以工作。您没有提到从哪里获得
evc2
变量。您确定这是一个有效的事件系列ID吗?我做了一个快速测试,让脚本创建一个事件,将它的ID存储在一个变量中,然后使用
deleteEventSeries()
删除带有该ID的事件,效果很好。我发布的是一个摘要,所以evc2是在其他地方定义的,我刚刚尝试了一个简化版本,确实有效,看来我做了一些修改evc2的事情。我会再次检查我的代码,如果我发现了什么,会让你们保持更新