Google apps script 我的代码中的意外错误是什么?

Google apps script 我的代码中的意外错误是什么?,google-apps-script,google-calendar-api,Google Apps Script,Google Calendar Api,我试图在谷歌应用程序脚本中创建一个日历事件,它类似于日历中使用的“快速添加”格式。我使用了createEventFromDescription方法,我检查了执行记录,它成功地创建了事件,但是脚本在运行脚本时显示了一个错误 错误消息为“遇到错误:发生意外错误” 我不知道我做错了什么,这造成了事件。代码如下: function doGet(){ var app = UiApp.createApplication().setTitle('QuickAdd Events'); //Create

我试图在谷歌应用程序脚本中创建一个日历事件,它类似于日历中使用的“快速添加”格式。我使用了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;
 }
}

您正在调用getElementById('panel'),但没有名为'panel'的小部件。。。最近的面板是名为“parent”的面板,是要隐藏的面板吗

这是错误的全文吗?没有行号?是的,当我运行它时会出现一个弹出窗口。没有行号。这是什么类型的运行时错误?我想是这样,我会试试。事实上我很确定它是:-)这是这个错误的典型错误消息,在我开始使用UiApp时经常发生请考虑接受答案。我想创建一个按钮,在左面板中添加另一个文本框来保存另一个事件。我创建一个函数:
函数createAnotherEvent(app,panel){
`var eventTitleLabel=app.createLabel('Event Title:');`var eventTitle=app.createTextBox().setName('eventTitle');`panel.add(eventTitleLabel)`.add(eventTitle);`code>}我试图将按钮链接到此函数,但没有成功:`var panelHandler=app.createServerClickHandler(createAnotherEvent(app,左));`<代码>panelHandler.addCallbackElement(左)
另一个EventButton.addClickHandler(panelHandler)无法向EventHandler添加参数。只需在函数app=UiApp.getActiveApplication()和app.getElementById('panel')中使用,它就会起作用。请注意,最好发布一个新问题,而不是注释…;-)