我正在尝试通过表单获取Google API日历条目。我已经在脚本和仪表板上启用了API。
我有两个问题,从主脚本调用create event函数,并使变量在两者之间起作用。
我已经注意到create event脚本的基本变体,因为一旦它开始工作,我就需要完整API的更高级功能。
主脚本与上面提到的部分配合使用,但是无论尝试如何,我都无法使API方法正常工作,并且搜索也没有给我任何答案。
我们将非常感谢您的帮助
谢谢
function onSubmit(e){
var formResponses = e.response.getItemResponses();
var submitterEmail = e.response.getRespondentEmail();
var submitionDate = e.response.getTimestamp();
var eventName = formResponses[0].getResponse();
var eventDescription = formResponses[1].getResponse();
var moduleCode = formResponses[2].getResponse();
var organiser = formResponses[3].getResponse();
var organiserEmail = formResponses[4].getResponse();
var eventRoom = formResponses[5].getResponse();
var techTeam = formResponses[6].getResponse();
var supportRequired = formResponses[7].getResponse();
var supportDescription = formResponses[8].getResponse();
var eventRepeat = formResponses[9].getResponse();
if(techTeam=="Performance Studios"){var calId = "Redacted"};
if(techTeam=="Televison Studios"){var calId = "TV Calendar"};
if(techTeam=="Science and Publishing"){var calId = "Science Calendar"};
var finalDescription = 'Organiser: ' + organiser + '\n \n' + 'Module Code: ' + moduleCode + '\n \n' + 'Description of the Event: ' + eventDescription + '\n \n' +
'Type of support: ' + supportRequired + '\n \n' + 'Description of Support: ' + supportDescription + '\n \n';
var calendarId = CalendarApp.getCalendarById(calId);
// create attachments
//Single Day Event
if(eventRepeat=="Single Day Event")
{
var supportDate = (formResponses[10].getResponse());
var supportStart = (formResponses[11].getResponse());
var eventStart = formResponses[12].getResponse();
var eventEnd = formResponses[13].getResponse();
var supportEnd = (formResponses[14].getResponse());
var start = new Date(supportDate+"T"+supportStart+":00.000Z");
var end = new Date(supportDate+"T"+supportEnd+":00.000Z");
if (end<start){var end = new Date(end.setDate(end.getDate()+1))};
if (eventStart!=""){var finalDescription = eventName + ' Start Time: ' + eventStart +'\n' + eventName + ' End Time: ' + eventEnd + '\n \n' + 'Organiser: ' + organiser + '\n \n' + 'Module Code: ' + moduleCode + '\n \n' + 'Description of the Event: ' + eventDescription + '\n \n' + 'Type of support: ' + supportRequired + '\n \n' + 'Description of Support: ' + supportDescription + '\n \n'};
//calendarId.createEvent(eventName,start, end,{description: finalDescription, location: eventRoom, guests: submitterEmail +' , '+ organiserEmail, sendInvites:true});
};
};
function createEvent() {
var event = {
summary: eventName,
location: eventRoom,
start: {dateTime: start},
end: {dateTime: end},
// Bold Red background.
colorId: 11
};
event = Calendar.Events.insert(event, calendarId);
};