【问题标题】:Google Apps Script for Calendar: searchfilter?用于日历的 Google Apps 脚本:searchfilter?
【发布时间】:2017-05-21 23:45:18
【问题描述】:

我正在尝试为 Google 日历编写一个 Google Apps 脚本,该脚本会自动拒绝任何没有描述的邀请。

我正在使用getEvents 调用来检索特定窗口内的事件,但我还想过滤它以仅包含状态为 INVITED 的事件。我写了一些有用的东西,但只有当我用 getMyStatus 检查我的状态时。无论我如何尝试将 searchFilter 与 CalendarApp.GuestStatus.Invited 一起使用,我都无法通过该选项检索事件。有什么建议吗?

这是我的工作代码。

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);
        }
      }
    }
  }
};

【问题讨论】:

    标签: google-apps-script enums google-calendar-api


    【解决方案1】:

    试试这个:

    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);
    
            }
    
        });
    
    }
    

    【讨论】:

      猜你喜欢
      • 2019-07-05
      • 2014-11-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-04-21
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多