[英]Is there any way to do a for each all Google Forms created by a Gmail account?
I am trying to get a list with all the google forms created by a specific google account (my own Gmail account BTW), in order to list them, get each ID and after that, be able to extract the responses spreadsheet associated to it and consolidate everything in a big home-made merge table.我正在尝试获取由特定谷歌帐户(我自己的 Gmail 帐户顺便说一句)创建的所有谷歌 forms 的列表,以便列出它们,获取每个 ID,然后,能够提取与其关联的响应电子表格和将所有内容合并到一个大型的自制合并表中。
I have tried using FormApp
, but it appears to be only for just one form.我曾尝试使用
FormApp
,但它似乎只适用于一种形式。 I have tried filtering all the existing files in DriveApp
, but no luck at all.我尝试过滤
DriveApp
中的所有现有文件,但一点运气都没有。
You can use DriveApp.getFilesByType() to get all Google Forms in your drive using MimeType.GOOGLE_FORMS .您可以使用DriveApp.getFilesByType()在您的驱动器中使用MimeType.GOOGLE_FORMS获取所有 Google Forms。
Once you get all the forms, you can check its owner's email address using File.getOwner() User.getEmail() before listing all your File Ids'.获得所有 forms 后,您可以在列出所有文件 ID 之前使用File.getOwner() User.getEmail()检查其所有者的 email 地址。
After that, you can open each form using FormApp.openById() and use Form.getDestinationId() to get the response destination.之后,您可以使用FormApp.openById()打开每个表单并使用Form.getDestinationId()获取响应目标。
Sample Code:示例代码:
var formList = DriveApp.getFilesByType(MimeType.GOOGLE_FORMS);
var myForms = [];
while (formList.hasNext()) {
var form = formList.next();
var ownerEmail = form.getOwner().getEmail();
Logger.log(form.getName());
Logger.log(ownerEmail);
if(ownerEmail == "myEmail@example.com"){
myForms.push(form.getId());
}
}
myForms.forEach(id=>{
var form = FormApp.openById(id);
var destinationId = form.getDestinationId();
var destinationType = form.getDestinationType();
Logger.log(destinationId);
Logger.log(destinationType);
})
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.