Google Apps脚本-Advanced日历服务



我想与用户共享一个Google表格,使他们可以在日历中添加多天的全天事件。由于Google没有提供一个功能,所以我疲倦了各种解决方法。createEvent(标题,启动时间,末日(并不完美,并显示DateTime,CreateEventFromDescription(Description(不允许元数据(例如描述(,因此我尝试使用高级日历服务。从启用高级日历服务后,我已经阅读的内容,您应该能够使用Google日历API,就好像您使用了应用程序脚本的内置日历服务一样。如果我在板脚本编辑器中运行此内置功能,它可以使用,我可以制作纸张的副本,将其发送给其他人,他们也可以运行该功能
var event = CalendarApp.getDefaultCalendar().createEvent('Apollo 11 Landing', new Date('July 20, 1969 20:00:00 UTC'), new Date('July 20, 1969 21:00:00 UTC'), {location: 'The Moon'}); Logger.log('Event ID: ' + event.getId());
如果我使用高级日历服务并使用下面的代码,这基本上是他们的示例,我可以在脚本编辑器中运行该功能,但是如果我制作表格并将其发送给其他人,请尝试错误"未找到项目(数字(,也不能用于API调用"。任何人都可以看到我在做错什么。

function createEvent() {
var calendarId = 'primary';
var event = {
summary: 'Lunch Meeting',
location: 'The Deli',
description: 'To discuss our plans for the presentation next week.',
start: {
  date: "2017-05-21"
},
end: {
  date: "2017-05-24"
},
attendees: [
  {email: 'alice@example.com'},
  {email: 'bob@example.com'}
],
// Red background. Use Calendar.Colors.get() for the full list.
colorId: 11
};
event = Calendar.Events.insert(event, calendarId);
Logger.log('Event ID: ' + event.getId());
}

嗯,我不知道为什么您会收到API调用错误;但是,createEventFromDescription返回事件对象,因此您可以添加类似的描述:

var event = createEventFromDescription("Some event 4/25 - 4/30");
event.setDescription("This is a description.");

CalendarApp不如高级日历服务(例如,您无法设置事件颜色(那么健壮,但它可能足够适合您的目的。

最新更新