【发布时间】: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