为“表单提交"触发器指定表单

问题描述:

我有两个 Google 表单,它们将数据发送到单个电子表格中的两个选项卡.

I have two google forms, which send data to two tabs in a single spreadsheet.

我已经设置了一个具有两个功能的脚本.我希望第一个函数在提交第一个表单时运行.并且,在提交第二个表单时运行的第二个函数.

I have set up a script with two functions. I would like the first function to run on submission of the first form. And, the second function to run on submission of the second form.

问题是:在设置onformsubmit的触发器时,不允许你指定哪个表单.

因此,每当完成第一个表单时,它都会运行这两个功能.

Therefore, whenever completing the first form, it runs both functions.

问题:如何限制功能仅在提交特定表单时运行?

我刚刚看了一些文档,发现了这个:

I was just looking at some documentation and found this:

Form 文档

它指出:

创建并返回一个绑定到给定表单的 FormTriggerBuilder.

Creates and returns a FormTriggerBuilder tied to the given form.

还有:

var form = FormApp.openById('1234567890abcdefghijklmnopqrstuvwxyz');
 ScriptApp.newTrigger('myFunction')
     .forForm(form)
     .onFormSubmit()
     .create();

onFormSubmit

该代码似乎与特定表单相关联.

That code seems to be tied to a specific form.