【问题标题】:update fields form Google Apps Script从 Google Apps 脚本更新字段
【发布时间】:2012-12-24 17:26:51
【问题描述】:

我在更新表单字段的值时遇到问题。我无法更新其各自文本框中的日期,接收值的电子表格仅在我刷新页面后显示值(Ui 和电子表格都嵌入在 Google 网站中)

变量日期,显式为全局变量

var date=new Date();

文本框

var DataTextBox=app.createTextBox().setId('Data').setName('Data').setValue(date).setReadOnly(true).setText(Utilities.formatDate(date, 'GMT -02:00', 'dd/MM/yyyy HH:mm:ss'))

处理程序

var clickHandler2=app.createServerHandler('updateAll');
button.addClickHandler(clickHandler2);
clickHandler2.addCallbackElement(panel);

函数(更新了其他字段,但工作正常)

function updateAll(e) {
  //DataTextBox.setValue(date).setReadOnly(true).setText(Utilities.formatDate(date, 'GMT -02:00', 'dd/MM/yyyy HH:mm:ss'));
  var newDate=date;
  app.getElementById("Data").setValue(newDate);
  app.getElementById("TicketId").setValue("");
  app.getElementById("TicketType").setValue(TicketTypeArray[0]);
  app.getElementById("DemandedBy").setValue(DemandedByArray[0]);
  app.getElementById("Analyst").setValue(AnalystArray[0]);
  app.getElementById("Description").setValue("");
}

如何更新日期字段以及如何使电子表格显示表单提交的最后数据?

【问题讨论】:

  • 您在处理程序函数的末尾是否缺少“返回应用程序”? 'newDate=date' 背后的想法是什么 if 'date=new Date()' 我不明白你为什么这样做......
  • 我认为使用与其他字段相同的逻辑,日期会更新,使脚本再次写入日期的值。
  • updateAll() 也需要先var app = UiApp.getActiveApplication();
  • 使用dateBox

标签: google-apps-script


【解决方案1】:

您必须添加“返回应用程序”才能在 gui 中显示更新的字段。

【讨论】:

  • 你之前做过var app = UiApp.getActiveApplication();吗?如果是这样,它应该已经更新了谷歌 appscript 中的 GUI。
  • 在设置文本字段之前尝试设置newDate转换为字符串。
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多