我对编码非常陌生,在尝试保存脚本时不断收到此错误。
代码如下:
function myFunction() {
const calID = '*email*'
const cal = CalendarApp.getCalendarById(calID)
const startTime = new Date('2024-04-01 00:00 AM');
const endTime = new Date('2024-04-30 11:59 PM');
const events = cal.getEvents(startTime,endTime)
ScriptApp
.newTrigger('findNewEvents')
.forUserCalendar(cal)
.onEventUpdated()
.create()
SpreadsheetApp.
for (x = 0 ; x<events.lenght;x++);{
let title = event[x].getTitle(),
console.log(title);
}
}
我想在 Google 日历中添加新活动时设置一个触发器,将这些活动的信息添加到 Google 表格中(客人电子邮件等信息,以及客人在活动中输入的其他信息)。
试试这个方法:
function myFunction() {
const calID = '*email*'
const cal = CalendarApp.getCalendarById(calID)
const startTime = new Date(2024, 3, 1, 0, 0);
const endTime = new Date(2024, 3, 30, 11, 59);
const events = cal.getEvents(startTime, endTime)
//ScriptApp.newTrigger('findNewEvents').forUserCalendar(cal).onEventUpdated().create(); //If you have been running this you probably have a lot of triggers. I'd take a look and delete some if necessary
for(let x = 0; x < events.length; x++) {
let title = events[x].getTitle();
console.log(title);
}
}
不确定为什么每次运行该函数时都会创建一个新的触发器。对我来说这似乎是个坏主意。