有什么方法可以为每个 Gmail 帐户创建的所有 Google 表单做一个?

Is there any way to do a for each all Google Forms created by a Gmail account?

我正在尝试获取由特定 google 帐户(我自己的 Gmail 帐户 BTW)创建的所有 google 表单的列表,以便列出它们,获取每个 ID 并在之后能够提取与其关联的响应电子表格,并在一个大型自制合并中合并所有内容 table。

我试过使用 FormApp,但它似乎只适用于一种形式。 我已经尝试过滤 DriveApp 中的所有现有文件,但一点也不成功。

您可以使用 DriveApp.getFilesByType() to get all Google Forms in your drive using MimeType.GOOGLE_FORMS.

获得所有表格后,您可以在列出所有文件 ID 之前使用 File.getOwner() User.getEmail() 检查其所有者的电子邮件地址。

之后,您可以使用 FormApp.openById() and use Form.getDestinationId() 打开每个表单以获取响应目的地。

示例代码:

  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);
  })