Javascript 使用谷歌应用程序脚本的确认消息框

Javascript 使用谷歌应用程序脚本的确认消息框,javascript,google-apps-script,Javascript,Google Apps Script,我已经实现了谷歌应用程序脚本代码来显示确认消息,我成功地使用标签显示消息,但我尝试在一个框中而不是在标签中显示确认消息,这样用户就可以清楚地看到他们成功提交了文件,并且可以点击该框中的OK按钮。我尝试使用下面的代码实现此目标,但它显示以下错误消息: “遇到错误:SpreadsheetApp.getUi()只能从绑定到新应用程序的脚本调用。” 谷歌表单的版本。” 这是我为编写GoogleApps脚本而创建的新Google电子表格,但我复制并粘贴了现有代码 这是我试图用来显示确认消息框的代码(显示错

我已经实现了谷歌应用程序脚本代码来显示确认消息,我成功地使用标签显示消息,但我尝试在一个框中而不是在标签中显示确认消息,这样用户就可以清楚地看到他们成功提交了文件,并且可以点击该框中的OK按钮。我尝试使用下面的代码实现此目标,但它显示以下错误消息:

“遇到错误:SpreadsheetApp.getUi()只能从绑定到新应用程序的脚本调用。” 谷歌表单的版本。”

这是我为编写GoogleApps脚本而创建的新Google电子表格,但我复制并粘贴了现有代码

这是我试图用来显示确认消息框的代码(显示错误消息,如上所示):

以下是我在标签中成功显示确认消息的代码:

// Create form to hold the file upload buttons for choosing a file and uploading

var form = app.createFormPanel().setId('frm').setEncoding('multipart/form-data');
  var formContent = app.createVerticalPanel();
  form.add(formContent);
  formContent.add(app.createLabel('All of the following files must be submitted prior to completing the form').setHeight('25px').setStyleAttributes(_lbl).setStyleAttribute('font-size','20px'));


  formContent.add(app.createLabel('Reference Letter').setHeight('20px').setStyleAttributes(_lbl));
  formContent.add(app.createFileUpload().setName('Reference'));
  formContent.add(app.createLabel('Reference Letter 2').setHeight('20px').setStyleAttributes(_lbl));
  formContent.add(app.createFileUpload().setName('Reference2'));
  formContent.add(app.createLabel('Reference Letter 3').setHeight('20px').setStyleAttributes(_lbl));
  formContent.add(app.createFileUpload().setName('Reference3'));

formContent.add(app.createSubmitButton('Submit File Uploads'));

function doPost(e) {
  // data returned is a blob for FileUpload widget
  var fileBlob = e.parameter.Reference;
  var doc = DocsList.createFile(fileBlob);
  var app = UiApp.getActiveApplication();

  var fileBlob2 = e.parameter.Reference2;
  var doc = DocsList.createFile(fileBlob2);
  var app = UiApp.getActiveApplication();

  var fileBlob3 = e.parameter.Reference3;
  var doc = DocsList.createFile(fileBlob3);
  var app = UiApp.getActiveApplication();

  //Display a confirmation message
  var label = app.createLabel('Thank You for uploading files').setStyleAttribute('font-weight','bold').setStyleAttribute('font-size','1.1em');
  app.add(label);

  return app;

}
有没有办法在盒子里而不是在标签上显示确认信息?我还必须显示程序其他部分的确认消息

谢谢

您可以使用或代替标签。查看链接文档以了解详细信息


另一方面,doPost()函数代码将
var-app
设置三次,这是不必要的。您可能还需要编辑代码,以说明并非所有3个被选择和上载的文件。

azawaza,非常感谢您的回答。我按照上面列出的文档中的描述应用了PopupPanel。PopupPanel正在工作,但我确实在PopupPanel.setTag(“感谢您的应用程序”).setStyleAttribute(“颜色”、“蓝色”)中使用了字符串文本;但我的文本并没有显示在弹出窗口中。你知道我错过了什么吗。非常感谢您的建议。弹出面板是一个面板,您不能直接在其中写入文本,您应该在其中添加标签或HTML小部件并将文本写入其中。顺便说一句,标签(在任何UiApp小部件上)实际上是一个不可见的字段,可以用来将字符串数据传输到服务器功能。它们是设计上看不见的。谢谢Serge insas,你的建议解决了在popupPanel中添加文本的问题。我对popupPanel使用了如下标签:popupPanel.add(app.createLabel(‘感谢您的应用’);
// Create form to hold the file upload buttons for choosing a file and uploading

var form = app.createFormPanel().setId('frm').setEncoding('multipart/form-data');
  var formContent = app.createVerticalPanel();
  form.add(formContent);
  formContent.add(app.createLabel('All of the following files must be submitted prior to completing the form').setHeight('25px').setStyleAttributes(_lbl).setStyleAttribute('font-size','20px'));


  formContent.add(app.createLabel('Reference Letter').setHeight('20px').setStyleAttributes(_lbl));
  formContent.add(app.createFileUpload().setName('Reference'));
  formContent.add(app.createLabel('Reference Letter 2').setHeight('20px').setStyleAttributes(_lbl));
  formContent.add(app.createFileUpload().setName('Reference2'));
  formContent.add(app.createLabel('Reference Letter 3').setHeight('20px').setStyleAttributes(_lbl));
  formContent.add(app.createFileUpload().setName('Reference3'));

formContent.add(app.createSubmitButton('Submit File Uploads'));

function doPost(e) {
  // data returned is a blob for FileUpload widget
  var fileBlob = e.parameter.Reference;
  var doc = DocsList.createFile(fileBlob);
  var app = UiApp.getActiveApplication();

  var fileBlob2 = e.parameter.Reference2;
  var doc = DocsList.createFile(fileBlob2);
  var app = UiApp.getActiveApplication();

  var fileBlob3 = e.parameter.Reference3;
  var doc = DocsList.createFile(fileBlob3);
  var app = UiApp.getActiveApplication();

  //Display a confirmation message
  var label = app.createLabel('Thank You for uploading files').setStyleAttribute('font-weight','bold').setStyleAttribute('font-size','1.1em');
  app.add(label);

  return app;

}