简体   繁体   English

如何为用户完成登录后将其添加到Google表单

[英]How do I add a login to a Google Form for users completing it

I have been reading and watching many tutorials online but I could not find something that I can initially load some kind of dialog box or login page with a single input text so then I can process that using apps script. 我一直在在线阅读和观看许多教程,但找不到最初可以用单个输入文本加载某种对话框或登录页面的东西,然后可以使用apps脚本进行处理。

onFormOpen() is not triggered on the user who completes the form. 填写表单的用户不会触发onFormOpen()。

On my onSubmitForm() function I have the following code: 在我的onSubmitForm()函数上,我有以下代码:

function onFormSubmit(e){
  var formResponses = FormApp.getActiveForm().getResponses();
  var formResponse = formResponses[formResponses.length-1];
  var itemResponses = formResponse.getItemResponses();
  for (var j = 0; j < itemResponses.length; j++) {
    var itemResponse = itemResponses[j];
    Logger.log('Last response to the question "%s" was "%s"',
               itemResponse.getItem().getTitle(),
               itemResponse.getResponse())
  }
}

Is there any way I can prevent from here the form being submitted with some kind of logic condition, for ex: execute the form submission only if certain field matches some condition? 我有什么办法可以阻止带有某种逻辑条件的表单提交,例如:仅当某些字段匹配某种条件时才执行表单提交?

Is there any way I can prevent from here the form being submitted with some kind of logic condition, for ex: execute the form submission only if certain field matches some condition? 我有什么办法可以阻止带有某种逻辑条件的表单提交,例如:仅当某些字段匹配某种条件时才执行表单提交?

You could use form rules : 您可以使用表单规则

You can create rules that people have to follow when they fill out your form. 您可以创建人们在填写表格时必须遵循的规则。 For example, if you ask for email addresses, you can make sure that people can only submit properly formatted email addresses. 例如,如果您要求提供电子邮件地址,则可以确保人们只能提交格式正确的电子邮件地址。

Regarding onFormOpen() there isn't a built-in trigger named that way. 关于onFormOpen(),没有以这种方式命名的内置触发器。 You could use that as name for an on open installable trigger but it only runs when the form editor is opened, not when the form view is opened. 您可以将其用作打开的可安装触发器的名称,但它仅在打开表单编辑器时运行,而不在打开表单视图时运行。

Regarding adding a custom logging, if you use a G Suite account you could limit the access to users from the same domain as your account but you could not limit access further this. 关于添加自定义日志记录,如果您使用G Suite帐户,则可以将访问权限限制为与该帐户来自同一域的用户,但不能对此进行进一步限制。

A hacky alternative is to take the source code from the form view and "adapt" it to be served by a Google Apps Script or host it on your own web server. 另一种怪异的选择是从表单视图中获取源代码,并“调整”源代码,以使其由Google Apps脚本提供服务或将其托管在您自己的Web服务器上。 This implies that you will inject your custom form rule/data validation. 这意味着您将注入自定义表单规则/数据验证。 The easier way is by using the old Google Forms and copy/paste the source code of the form but it's possible to use UrlFetch. 比较简单的方法是使用旧的Google表单并复制/粘贴表单的源代码,但是可以使用UrlFetch。

Another alternative is to use the HtmlService Service from Google Apps Script to create and serve your form which practically will give you complete control of your form behavior. 另一种选择是使用Google Apps脚本中的HtmlService服务创建并提供您的表单,这实际上将使您完全控制表单行为。 See Forms - HTML Service: Communicate with Server Functions 请参阅表单-HTML服务:与服务器功能进行通信

Related: 有关:

On https://webapps.stackexchange.com https://webapps.stackexchange.com

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

相关问题 使用Google登录表单登录后,如何将用户重定向到新页面? - How can I redirect users to a new page after they logged in with the Google login form? 如何自定义 WordPress 站点上的登录表单以允许用户查看和隐藏其密码? - How do I customize the login form on a WordPress site to allow users to view and hide their password? 如何将LinkedIn登录添加到Meteor? - How do I add LinkedIn login to Meteor? 如何防止登录用户访问登录页面? - how do i prevent logged in users from accessing the login page? 完成第一个功能后如何执行功能? - How do I execute a function after completing first function? Npm 安装未完成。 我该如何解决问题 - Npm install not completing. How do i fix the problem 完成Google表单后,如何在Google Spreadsheets中现有工作表的末尾创建新行? - How to create a new row at the end of an existing sheet in Google Spreadsheets after completing a Google Form? 我如何阻止用户在 React 上提交相同的表单 - how do i stop users from submitting the same form on react 如何防止用户通过表单伪造数据? - How do I keep users from spoofing data through a form? Google地图,用户创建标记,如何保存 - Google Map, Users Create Markers, How do I save
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM