我已经编写了下面的代码,并且在表单提交上,将为参数创建日历事件。但是我总是通过电子邮件收到失败:
TypeError:在对象Calendar中找不到函数createEvent。 (第59行,文件“创建事件”)。它没有找到日历,我已经通过CalendarID和CalendarName尝试了这个。
任何帮助都会感激不尽。
function CreateEvent(e) {
var Group = e.values[1];
var startTime = e.values[2];
var endTime = e.values[3];
var Activitytitle = e.values[4];
var Actlocation = e.values[5];
var ActivityDesc = e.values[6];
var AuthLeader = e.values[7];
var AuthLeaderNo = e.values[8];
var AuthLeaderPermit = e.values[9];
var LeaderCharge = e.values[10];
var LeaderChargeNo = e.values[11];
var LeaderEmail = e.values[12];
var Adults = e.values[13];
var Beavers = e.values[14];
var Cubs = e.values[15];
var Scouts = e.values[16];
var Explorers = e.values[17];
var Other = e.values[18];
var InTouchName = e.values[19];
var InTouchContact = e.values[20];
var ManagerEmail = e.values[21];
var RA = e.values[22];
var Rules = e.values[23];
var title = "(Pending) " + Activitytitle;
var Actdescription = "<h2>Activity Information</h2>" +
"<b>Group:</b> " + Group + " <br/>" +
"<b>Type of Activity:</b> " + Activitytitle + " <br/>" +
"<b>Activity Date Start:</b> " + startTime + " <br/>" +
"<b>Activity Date End:</b> " + endTime + " <br/>" + " <br/>" +
"<b>Location:</b> " + Actlocation + " <br/>" +
"<b>Brief Description of Activity:</b> " + ActivityDesc + " <br/>" + " <br/>" +
"<h2>Adventurous Activities Permit Information</h2>" +
"<b>Authorised Leader:</b> " + AuthLeader +" <br/>" +
"<b>Authorised Leader Contact Number:</b> " + AuthLeaderNo + " <br/>" +
"<b>Permit Details:</b> " + AuthLeaderPermit + " <br/>" + " <br/>" +
"<h2>Attendance Details</h2>" +
"<b>Leader in Charge:</b> " + LeaderCharge + " <br/>" +
"<b>Leader Contact Number:</b> " + LeaderChargeNo + " <br/>" +
"<b>Leader Email</b>: " + LeaderEmail + " <br/>" + " <br/>" +
"<b>Number of Adults (18+):</b> " + Adults + " <br/>" +
"<b>Non Uniform YP (Under 18):</b> " + Other + " <br/>" +
"<b>Number of Beavers:</b> " + Beavers + " <br/>" +
"<b>Number of Cubs:</b> " + Cubs + " <br/>" +
"<b>Number of Scouts:</b> " + Scouts + " <br/>" +
"<b>Number of Explorers/Young Leaders:</b> " + Explorers + " <br/>" + " <br/>" +
"<h2>Health and Safety Information</h2>" +
"<b>Line Managers Email Address:</b> " + ManagerEmail + " <br/>" + " <br/>" +
"<b>InTouch Contact:</b> " + InTouchName + " <br/>" +
"<b>InTouch Contact Number:</b> " + InTouchContact + " <br/>" + " <br/>" +
"<b>Risk Assessment Completed:</b> " + RA + " <br/>" +
"<b>Scout Association POR Guidelines Followed:</b> " + Rules;
var myCal = CalendarApp.getCalendarsByName('Activity Notifications');
Logger.log('Found %s matching calendars.', calendars.length);
myCal.createEvent (title, startTime, endTime, {
description : Actdescription,
location : Actlocation
});
}
答案 0 :(得分:0)
看起来你正在使用AppScript,CalendarApp.getCalendarsByName
会返回一个Calendar[]
数组,这就是它失败的原因。在数组中找到合适的Calendar,然后立即使用它调用createEvent
方法。