如何用值填充 Google 表单标题字段

How to populate Google Form title field with value

我正在寻找一种将值传递给多个 Google 表单 "Question Title" 的方法。

我有一个表格,其中一些问题需要用一个值填充——这是一个例子:

问题标题:对于截至 «fiscal_year_14» 的财政年度,您的拨款总额是多少?

其中 «fiscal_year_14» 是我存储在 Google 电子表格中的日期 (12/31/2014)。

Google form / Google App Scripts 这可能吗?

这是一段可以修改问题标题的代码。这将打开活动表单,获取所有项目,检查您的特定令牌的项目,然后用正确的日期替换它。此功能可以 运行 手动或作为计划任务。注意:活动表单不能以任何方式触发脚本。

function updateQuestion() {
  var form = FormApp.getActiveForm(),
      items = form.getItems(),
      title = "",
      token = "«fiscal_year_14»",
      HardCodeDate = "12/31/2014"; // you would look this up in your spreadsheet.

  for(var i in items){     
     title = items[i].getTitle();     
     if(title.indexOf(token) != -1){
        items[i].setTitle(title.replace(token, HardCodeDate));
     }
  }
}