根据Google表格电子表格中的动态数据更新Google表单字段 [英] Update Google Forms field based on dynamic data from a Google Sheets spreadsheet
问题描述
在 Google表单中,我们有一个下拉选择列表.
In a Google Form we have a pull down selection list.
项目列表可能会在每分钟之间变化.数据的主副本位于google docs电子表格的一列中.
The list of items may change from minute to minute. The master copy of the data is in a column in a google docs spreadsheet.
当用户访问表单时,我们希望他们看到下拉列表的最新副本,就像电子表格中的最新副本一样.
When a user accesses the form, we want them to see the latest copy of the pull down list as is current in the spreadsheet.
我没有看到使用触发器执行此操作的明显方法.例如,onOpen仅触发表单管理员,而不触发用户.有什么方法可以让我自动保持此表单的最新状态?
I don't see an obvious way to do this with triggers. onOpen, for example, only triggers for administrators of the form, not users. Is there a way I can keep this form up-to-date automatically?
这是我第一次使用Google文档,但是我在Excel脚本编写方面经验丰富.
This is my first time in google docs, but I'm very experienced in excel scripting.
推荐答案
工作流程与您所描述的有所不同.由于Google Apps脚本无法与访问表单的最终用户进行交互,因此无法对此做出反应.但是,您可以对电子表格中的更改做出反应,并更新表单选项以为下一个最终用户做准备.
The work flow needs to be a bit different than what you've described. Since there is no ability for Google Apps Script to interact with an end user accessing a Form, there's no way to react to that. However, you can react to changes in the spreadsheet, and update the form options in preparation for the next end user.
-
根据电子表格中选项的更新方式,您可以在此处使用可安装的触发器来对编辑或更改做出反应.
Depending on how the options get updated in the spreadsheet, you can use an installable trigger there, to react to an edit or a change.
如果该表单与包含选项的电子表格相关联,则可以使用 FormApp.openByUrl()
.否则,您需要将ID或URL明确提供给 FormApp.openById()
或.openByUrl()
.
If the form is associated with the spreadsheet containing the choices, you can get a handle on the form using Spreadsheet.getFormUrl()
, then pass the URL to FormApp.openByUrl()
. Otherwise you will need to provide the ID or URL explicitly to FormApp.openById()
or .openByUrl()
, respectively.
该电子表格触发器功能可以使用 ListItem.setChoiceValues()
.
That spreadsheet trigger function can modify the available selections for the relevant question by using ListItem.setChoices()
or ListItem.setChoiceValues()
.
这篇关于根据Google表格电子表格中的动态数据更新Google表单字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!