如何为填写用户的Google表单添加登录信息 [英] How do I add a login to a Google Form for users completing it

查看:232
本文介绍了如何为填写用户的Google表单添加登录信息的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在阅读和在线观看很多教程,但是我找不到一些可以使用单个输入文本加载某种对话框或登录页面的内容,然后我可以使用应用程序脚本处理。



onFormOpen()不会触发完成表单的用户。



在我的onSubmitForm()函数中,我有以下代码:

  function onFormSubmit(e){
var formResponses = FormApp.getActiveForm()。getResponses();
var formResponse = formResponses [formResponses.length-1];
var itemResponses = formResponse.getItemResponses(); (var j = 0; j< itemResponses.length; j ++){
var itemResponse = itemResponses [j];
Logger.log('最后回答问题'%s'是'%s'',
itemResponse.getItem()。getTitle(),
itemResponse.getResponse())


$ / code>

有没有什么办法可以阻止这里的形式存在提交了某种逻辑条件,例如:仅当特定字段匹配某些条件时才执行表单提交? $ b

有没有什么办法可以阻止这种形式被提交某种逻辑条件,例如:仅当某些字段匹配某些条件时才执行表单提交?

blockquote>

您可以使用表单规则


您可以创建规则,人们在填写表单时必须遵循这些规则。例如,如果您要求提供电子邮件地址,则可以确保用户只能提交格式正确的电子邮件地址。


关于onFormOpen( )没有以这种方式命名的内置触发器。您可以将其用作打开的可安装触发器的名称,但只能在打开表单编辑器时运行,而不能在表单视图打开时运行。



关于添加自定义日志记录,如果您使用G Suite帐户,则可以限制用户与您的帐户在同一个域中的访问权限,但您无法进一步限制访问权限。



是从表单视图获取源代码并将其修改为由Google Apps脚本提供服务或将其托管在您自己的Web服务器上。这意味着您将注入自定义表单规则/数据验证。更简单的方法是使用旧的Google窗体并复制/粘贴表单的源代码,但可以使用UrlFetch。



另一种方法是使用HtmlService服务从Google Apps脚本创建和提供您的表单,这实际上会让您完全控制您的表单行为。请参阅表单 - HTML服务:与服务器功能进行通信 p>

相关:



https:// webapps .stackexchange.com




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.

onFormOpen() is not triggered on the user who completes the form.

On my onSubmitForm() function I have the following code:

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. 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.

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. 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.

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. See Forms - HTML Service: Communicate with Server Functions

Related:

On https://webapps.stackexchange.com

这篇关于如何为填写用户的Google表单添加登录信息的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆