google-apps-script - 将事件从表单和电子表格插入谷歌日历(错误)

标签 google-apps-script

在过去的几个月里,我的办公室一直在使用一个系统,我们可以在其中提交谷歌表格以休假或旅行。此表单会自动填充 Google 表格,然后自动弹出到共享日历。今天它停止工作了。我进入了代码,但收到错误“ session 名称值无效(第 111 行,文件“代码””)。

我做了一些实验,如果我在工作时将“var calendarId”更改为 = 我的个人电子邮件地址,那么它可以毫无问题地发布到我的日历中。如果我将其改回共享日历地址,则会出现错误。

在这一点上,我认为我的代码没有损坏,我觉得我的机构(政府)限制了我使用代码发布到共享日历的能力。我在这里错过了什么吗?任何想法表示赞赏。谢谢!

/**
* Creates an event in the user's default calendar.
*/
function createEvent(title,startDt,endDt,desc,loc, col) {
var calendarId = 'THIS IS WHAT IS CAUSING THE PROBLEM';
Logger.log(typeof(startDt))
var start = new Date(startDt);
**var startISO = start.toISOString();**
var end = new Date(endDt);
var endISO = end.toISOString();
var event = {
summary: title,
location: loc,
description: desc,
start: {
dateTime: startISO
},
end: {
dateTime: endISO
},
// Sets the calendar color
colorId: col
};
event = Calendar.Events.insert(event, calendarId);
Logger.log('Event ID: ' + event.getId());
}

所以今天早上我进来了,广告我不再收到上周的无效错误。现在我收到一个新错误,“RangeError:日期无效。 (第 95 行,文件“代码”)

最佳答案

对我来说,使用颜色 ID 1-11 有效。
Calendar.Colors.get() 返回了更多的 id,但那些 >11 导致了那个错误

关于google-apps-script - 将事件从表单和电子表格插入谷歌日历(错误),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36206980/

相关文章:

google-apps-script - 如何在 Google Apps 脚本中加密/解密 URL 参数?

google-apps-script - 如何读取 Google 网上论坛的消息

email - 使用Google Script在Gmail中插入带有超链接的文本吗?

arrays - 如何对对象数组进行排序 - google-apps-script

javascript - 使用 GDrive 脚本仅显示一次对话框(实现脏位系统)

javascript - 在 Google Scripts 自定义函数中接受任意数量的参数?

google-apps-script - 使用 Google 应用程序脚本刷新从 Google 表格粘贴到 Google 幻灯片中的表格

javascript - 使用 google 脚本和 html 模板循环进入要点

autocomplete - Google表格未在自动完成中显示自定义功能

javascript - 使用 html 服务通过 google apps 脚本上传文件