[英]Apps Script and Google Sheets, Creating calendar event
When I try to run the following code when the start and end dates are the same (to create a calendar event from data submitted through Google Forms), I get this error: Exception: Event start date must be before event end date.当我尝试在开始日期和结束日期相同时运行以下代码(从通过 Google 表单提交的数据创建日历事件),我收到此错误:异常:事件开始日期必须在事件结束日期之前。
else if (approval == Approval.Approved) {
// If approved, create a calendar event.
CalendarApp.getCalendarById(email)
.createAllDayEvent(
'OOO - Out Of Office',
startDate,
endDate,
{
description: message,
guests: additionalEmail,
sendInvites: true,
});
Since employees can request a full or partial day off, I would like the script to be able to run even if the values are the same.由于员工可以请求全部或部分休假,我希望脚本能够运行,即使值相同。 How would I make this happen?
我将如何做到这一点?
Also, for background, I have very limited coding experience (next to nothing except for basic R), so if it's possible, please dumb it down for me.另外,对于背景,我的编码经验非常有限(除了基本的 R 之外几乎没有),所以如果可能的话,请为我简化它。 Thank you so much for your time and help!
非常感谢您的时间和帮助!
As per documentation ( https://developers.google.com/apps-script/reference/calendar/calendar ), you can:根据文档( https://developers.google.com/apps-script/reference/calendar/calendar ),您可以:
Create a one-day event like so: createAllDayEvent(title, date)像这样创建一个一日活动: createAllDayEvent(title, date)
.createAllDayEvent(
'OOO - Out Of Office',
startDate,
{
description: message,
guests: additionalEmail,
sendInvites: true,
});
Create multiple-day events like so: createAllDayEvent(title, startDate, endDate)像这样创建多天事件: createAllDayEvent(title, startDate, endDate)
.createAllDayEvent(
'OOO - Out Of Office',
startDate,
endDate,
{
description: message,
guests: additionalEmail,
sendInvites: true,
});
Create partial-day events like so: createEvent(title, startTime, endTime, options)像这样创建部分日事件: createEvent(title, startTime, endTime, options)
.createEvent(
'OOO - Out Of Office',
startTime,
endTime,
{
description: message,
guests: additionalEmail,
sendInvites: true,
});
With regard to times in Apps Script, here's a snippet of syntax:关于 Apps Script 中的时间,这里有一段语法:
new Date('July 20, 1969 20:00:00 UTC');
And docs link: https://developers.google.com/google-ads/scripts/docs/features/dates和文档链接: https ://developers.google.com/google-ads/scripts/docs/features/dates
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.