【问题标题】:How to distinguish between two forms connected to same Google SpreadSheet in Google Apps Script如何区分连接到 Google Apps Script 中同一个 Google SpreadSheet 的两个表单
【发布时间】:2020-10-21 15:47:13
【问题描述】:

我有两种不同的形式。它们中的每一个都连接到同一个电子表格。我还设置了一个 onFormSubmit(e) 触发器。现在我的问题是如何根据表单区分表单提交。我对这两种表单都有不同的逻辑,所以我需要获取一些标识符,通过它我可以检查要运行的代码?

function onFormSubmit(e) {
  // something like this
  // if submission from FormA then do foo()
  // else if submission from FormB then do bar() 
}

【问题讨论】:

  • 相同的电子表格但不同的工作表 - 你不能只使用例如 SpreadsheetApp.getActiveSpreadsheet().getSheets()[0]SpreadsheetApp.getActiveSpreadsheet().getSheets()[1] 来分别获取每个表单响应的工作表吗?

标签: google-apps-script google-sheets google-forms


【解决方案1】:

e.range.getSheet() 方法将为您提供将存储表单响应的工作表。

使用sheet.getFormUrl() 了解发送此响应的 Google 表单的 URL。使用 FormApp.openByUrl 获取 Google 表单的参考。

【讨论】:

    猜你喜欢
    • 2014-07-08
    • 1970-01-01
    • 2012-09-19
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-05-23
    • 1970-01-01
    相关资源
    最近更新 更多