简体   繁体   English

使用Google Apps脚本从Google表单回复中提取受访者电子邮件

[英]Extract Respondent Email from Google Forms Responses using Google Apps Script

I'm using Google Apps Scripts to handle response data from a Google Form, and the form asks the users to prove a username at the start of the form. 我正在使用Google Apps脚本来处理来自Google表单的响应数据,并且该表单要求用户在表单开始时证明用户名。 The usernames have been provided to them earlier. 用户名已提前提供给他们。 I'm now trying to match the given username to the email ID that was used to respond to the form ( setLimitOneResponsePerUser() has been set to true , thus all users have to be signed in to respond), using values in a spreadsheet. 我现在正尝试将给定的用户名与用于响应表单的电子邮件ID( setLimitOneResponsePerUser()已设置为true ,因此所有用户都必须登录以响应),使用电子表格中的值进行匹配。

But I can't seem to get a value from Response.getRespondentEmail() (returns blank) unless I have Form.setCollectEmail() set to true , which I'm trying to avoid, as that means they'll have to manually enter the email ID's every time. 但我似乎无法从Response.getRespondentEmail()获取值(返回空白),除非我将Form.setCollectEmail()设置为true ,我试图避免,因为这意味着他们必须手动输入每次都是电子邮件ID。

Is there a way to extract the email ID that was used to create a response? 有没有办法提取用于创建响应的电子邮件ID?

NOTE: I cannot use the event object as the script does not run on a ResponseTrigger , rather it runs daily at a given time, and iterates through all the submitted responses for that form. 注意:我不能使用事件对象,因为脚本没有在ResponseTrigger上运行,而是每天在给定时间运行,并遍历该表单的所有提交的响应。

Answering my own question, in case others check this thread out. 回答我自己的问题,万一其他人检查这个帖子。

So it turns out there currently isn't a way to auto-collect email address using Google Scripts unless either: 所以事实证明目前没有办法使用Google Scripts自动收集电子邮件地址,除非:

  1. Form.setCollectEmail() is set to true , in which case the respondent has to manually enter in an email ID each time (and can be faked, because it won't be cross-checked with the actual account used to sign in) Form.setCollectEmail()设置为true ,在这种情况下,响应者每次必须手动输入一个电子邮件ID(并且可以伪造,因为不会与用于登录的实际帐户进行交叉检查)

OR 要么

  1. The script runs on a Form ResponseTrigger , in which case the associated email ID will be part of the Event object e . 该脚本在Form ResponseTrigger上运行,在这种情况下,关联的电子邮件ID将成为Event对象e But this method cannot be used for analysing responses at a later stage. 但是这种方法不能用于分析后期的响应。

Unfortunate that this hasn't been implemented in Google Apps Script yet, but let's see what happens in the future. 遗憾的是,这尚未在Google Apps脚本中实现,但让我们看看将来会发生什么。

Hope this is helpful to anyone else who stumbles upon this thread. 希望这对任何偶然发现此线程的人都有帮助。

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

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