简体   繁体   English

在Google Form应用程序脚本中运行onload函数

[英]running onload function in Google Form app script

I have a Google Form and a script and a script bound to the form. 我有一个Google表单和一个脚本以及与该表单绑定的脚本。 I'm trying to get a function to run when a user fill in the form. 我正在尝试让用户填写表单时要运行的功能。

But the only function I get to run is when a hook it to the OnFormSubmit trigger. 但是,我要运行的唯一功能是将其钩接到OnFormSubmit触发器上。 No other function is running, no matter what I try. 无论我尝试什么,都没有其他功能在运行。

Can I run a function i Google App Script on initial load when a user is filling the form? 用户填写表单时,我可以在初次加载时运行Google App脚本中的功能吗? Is this possible? 这可能吗?

Thanks 谢谢


More details (I'll accept some other way to accomplish the task): 更多详细信息(我将接受其他方式完成任务):

the function should capture some url parameters I pass to the form, and send it over to Google Analytics... I believe that part is solved here: Google Forms & The Measurement Protocol 该函数应该捕获我传递给表单的一些url参数,然后将其发送给Google Analytics(分析)...我相信这里已解决了部分问题: Google表单和度量协议

As the form has several pages, the parameters I pass to the first page gets lost when the user goes to next pages, so I cannot capture them when submitting the form - therefore I'm trying to do it whenever the users first edits the form. 由于表单有多个页面,当用户转到下一页时,传递给第一页的参数会丢失,因此在提交表单时我无法捕获它们-因此,每当用户首次编辑表单时,我都会尝试执行此操作。

I tried to add the params as prefilled fields on a hidden page, but if it is hidden then it too gets lost on submitting... 我试图将参数添加为隐藏页面上的预填充字段,但是如果它被隐藏了,那么在提交时也将丢失...

Since Sandy did not write out an answer, I will. 由于桑迪没有写出答案,我会的。

You cannot execute Apps Script as part of a form when the user visits it. 用户访问表单时,您不能将其作为表单的一部分执行。 You can't modify a form as the user is filling it out (Dynamic form...etc). 您无法在用户填写表单时对其进行修改(动态表单...等)。 If you need this type of behavior, you will need to create your own form as part of a Apps Script Web App. 如果您需要这种行为,则需要创建自己的表单作为Apps Script Web App的一部分。

Web App information: https://developers.google.com/apps-script/guides/web 网络应用信息: https : //developers.google.com/apps-script/guides/web

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM