我正在尝试在Google App Script中创建一个日历活动,它类似于" QuickAdd"日历中使用的格式。我使用了createEventFromDescription方法,检查了执行脚本,然后成功创建了事件,但脚本在运行脚本时显示错误。
错误消息是"遇到错误:发生了意外错误"
我不知道我做错了什么,它创造了这个事件。以下是代码:
function doGet(){
var app = UiApp.createApplication().setTitle('QuickAdd Events');
//Create a penel which holds all the form elelemnts
var parent = app.createHorizontalPanel().setId('parent');
var left = app.createVerticalPanel().setId('left');
var right = app.createVerticalPanel().setId('right');
var eventTitleLabel = app.createLabel('Event Title:');
var eventTitle = app.createTextBox().setName('eventTitle');
var eventButton = app.createButton('Create Events');
var cancelButton = app.createButton('Cancel');
left.add(eventTitleLabel)
.add(eventTitle);
right.add(eventButton)
.add(cancelButton);
var eventHandler = app.createServerClickHandler('createEvents');
eventHandler.addCallbackElement(left);
//Add this handler to the button
eventButton.addClickHandler(eventHandler);
parent.add(left)
.add(right);
app.add(parent);
app.close();
return app;
}
function createEvents(e){
//Get the active application
var app = UiApp.getActiveApplication();
try{
//get the entries;
var event = e.parameter.eventTitle;
//Get the calendar
var cal = CalendarApp.getDefaultCalendar();
cal.createEventFromDescription(event);
app.add(app.createLabel('Event created Successfully'));
//make the form panel invisible
app.getElementById('panel').setVisible(false);
return app;
}
//If an error occurs, show it on the panel
catch(e){
app.add(app.createLabel('Error occured: '+e));
return app;
}
}
答案 0 :(得分:0)
您正在调用getElementById(' panel')但没有名为' panel' ...最近的面板名为' parent',是那个你要隐藏的人?