使用应用程序脚本的高级日历服务添加一个提醒到现有的谷歌日历事件



我是Javascript和Stackoverflow的新手。我们最近从Microsoft Exchange迁移到Gmail,我正在尝试将一些团队流程自动化,使它们更易于用户使用和管理。其中之一是休假请求。在这里的社区的帮助下,我能够编写一个Google Apps脚本,更新共享的团队日历与Time-Off请求。对于一个新的请求,我创建了一个黄色的日历事件,因为它是自由的,所以它不会阻塞日历中的时间,也没有提醒(这是我想要的)。一旦请求被批准,我将事件颜色更新为绿色,从free变为busy,并添加一个提醒。除了提醒,一切都很好。我尝试了很多方法,但都不起作用。下面是相关代码。任何帮助都非常感谢!!PS.我使用的是高级日历服务

if ((requestStatus == "Approved") || (eventStatus == "confirmed")) {
var eventReminders = "{method: email, minutes: 900}";
} else {
var eventReminders = null;  //No reminders
}
//var eventReminders = setEventReminders(requestStatus); //set calendar reminders
// Compose event details based on the data read from the relevant row in the sheet
var newEvent = {
summary: 'Time-Off (' + requestStatus + ') ' + requestorName,
description: eventDescription,
colorId: colorE,
transparency: eventTransparency,
reminders: { 
useDefault: false, 
overrides: [ 
eventReminders 
]
},
start: {
date : startDate //use date instead of dateTime to create full day event so the event will pin on the top of the calendar
},
end: {
date : endDate
},
attendees: [
{email: requestorEmail}
]
};
//Create the event in the calendar  
updateCalendar (eventAction, newEvent, rowE, eventRequestID);
}

您可以使用以下方法:

  • CalendarEvent.AddPopupReminder(minutesBefore)
  • CalendarEvent.AddSmsReminder(minutesBefore)
  • CalendarEvent.AddEmailReminder(minutesBefore)

。(来源:https://gist.github.com/pricco/fd8ae2c8af51a5f6370ed15df83578e4)

var reminder_mins = 30; // 30 mins 
if (!targetEvent) { 
if (sourceEvent.isAllDayEvent()) {
targetEvent = targetCalendar.createAllDayEvent(sourceEvent.getTitle(), sourceEvent.getStartTime(), sourceEvent.getEndTime());
} else {
targetEvent = targetCalendar.createEvent(sourceEvent.getTitle(), sourceEvent.getStartTime(), sourceEvent.getEndTime());
targetEvent.addPopupReminder(reminder_mins)
}

相关内容

  • 没有找到相关文章

最新更新