Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/google-apps-script/6.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 Apps Script_Enums_Google Calendar Api - Fatal编程技术网

Google apps script 日历的谷歌应用脚本:搜索过滤器?

Google apps script 日历的谷歌应用脚本:搜索过滤器?,google-apps-script,enums,google-calendar-api,Google Apps Script,Enums,Google Calendar Api,我正在尝试为谷歌日历编写一个谷歌应用程序脚本,自动拒绝任何没有说明的邀请 我正在使用调用来检索某个窗口中的事件,但我也希望筛选该窗口,以便只包含状态为“已邀请”的事件。我写了一些有用的东西,但只有当我用getMyStatus检查我的状态时。无论我如何尝试将searchFilter与CalendarApp.GuestStatus.Invested一起使用,我都无法检索通过该选项的事件。有什么建议吗 这是我的工作代码 function processInvites() { var calenda

我正在尝试为谷歌日历编写一个谷歌应用程序脚本,自动拒绝任何没有说明的邀请

我正在使用调用来检索某个窗口中的事件,但我也希望筛选该窗口,以便只包含状态为“已邀请”的事件。我写了一些有用的东西,但只有当我用getMyStatus检查我的状态时。无论我如何尝试将searchFilter与CalendarApp.GuestStatus.Invested一起使用,我都无法检索通过该选项的事件。有什么建议吗

这是我的工作代码

function processInvites() {
  var calendar = CalendarApp.getCalendarById("mycalendar@google.com");
  var now = new Date();
  var then = new Date(now.getTime() + (1000 * 60 * 60 * 24 * 7));
  var events = [];

  var loopEvents = calendar.getEvents(now, then);

  if(loopEvents.length > 0){
    for(j in loopEvents){
      if(loopEvents[j].getMyStatus() == CalendarApp.GuestStatus.INVITED){
        //if this event has no notes
        if(loopEvents[j].getDescription() == ""){
          loopEvents[j].setMyStatus(CalendarApp.GuestStatus.NO);
        }
      }
    }
  }
};
试试这个:

function processInvites() {

    var cal = CalendarApp.getCalendarById("yourcalendar@google.com"),
        now = Date(),
        then = new Date(now.getTime() + (1000 * 60 * 60 * 24 * 7));

    cal.getEvents(now, then).forEach(function(event) {

        if (event.getMyStatus() == CalendarApp.GuestStatus.INVITED && event.getDescription() == "") {

            event.setMyStatus(CalendarApp.GuestStatus.NO);

        }

    });

}