【问题标题】:Why do I get an 'Invalid argument: url' error in the openByUrl(formURL) call?为什么我在 openByUrl(formURL) 调用中收到“无效参数:url”错误?
【发布时间】:2013-05-24 22:45:16
【问题描述】:

我在 Google Apps 电子表格中创建了一个表单,我正在尝试在我的脚本中找出一些表单参数数据。

在以下代码中,我不明白为什么我在该行收到“无效参数”错误

var myForm = FormApp.openByUrl(formURL);

即使日志显示我认为是有效的formURL 字符串。

function myFunction() {
  var ss  = SpreadsheetApp.getActive();
  var formURL = ss.getGetFormURL();
  Logger.log('Spreadsheet\'s formURL: %s', formURL);

  var myForm = FormApp.openByUrl(formURL);  // Google script shows the ERROR here
  Logger.log('Form PublishedURL: %s', myForm.getPublishedUrl());

}

【问题讨论】:

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


【解决方案1】:

尝试使用其 ID 而不是 URL 打开表单。您可以从其 URL 中找到表单的 ID。

 var myForm = FormApp.openById(id)

【讨论】:

    【解决方案2】:

    openById 和 openByUrl 仅适用于新表单服务。因此,如果表单是使用旧服务创建的,它将无法正常工作。见:

    http://code.google.com/p/google-apps-script-issues/issues/detail?id=2866

    【讨论】:

      猜你喜欢
      • 2011-10-08
      • 2022-01-18
      • 1970-01-01
      • 1970-01-01
      • 2011-11-05
      • 1970-01-01
      • 2017-11-30
      • 1970-01-01
      • 2019-04-02
      相关资源
      最近更新 更多