重复出现的一般性错误消息Google Apps脚本 [英] Recurring generic error message Google Apps Script

查看:59
本文介绍了重复出现的一般性错误消息Google Apps脚本的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

不确定这是否重要,但我使用的是非营利性GSuite.ENDEDIT :::

Not sure if this matters but I am using G Suite for Nonprofits.END ::

第一次尝试手动运行此脚本时,我一直收到此错误消息:

I keep getting this error message upon attempting to manually run this script for the first time:

很抱歉,发生服务器错误.请稍等,然后重试. (第2行,文件代码")).

We're sorry, a server error occurred. Please wait a bit and try again. (line 2, file "Code")).

我已保存它并已授权它的权限.我只是试图执行脚本以获取所有现有响应的编辑URL.

I have saved it and authorized its permissions already. I am simply trying to execute the script to get all of the existing responses' edit URLs.

没有与此相关的触发器.该脚本旨在从Google表单获取编辑响应网址.表单中启用了提交后编辑"功能,并且由谁来填写表单设置为公开"(这并不重要,因为我是表单的所有者).

There are no triggers associated with this. The script is intended to get the edit response URLs from a Google Form. "Edit after submit" is enabled in the Form, and it is set to public in regards to who can complete the form (not that this should matter since I am the owner of the form).

我在许多其他项目中都以这种精确的形式使用了此脚本,完全没有问题.我还尝试了一个我知道可以完成此任务的脚本,但返回了相同的错误消息.该错误消息始终引用具有ID/URL形式的代码行.我已经验证了表单ID.感谢您的帮助.

I use this script in this exact form on many other projects with no issues at all. I have also tried a different script for this task that I know works, with the same error message returned. The error message always references the line of code with the form ID/URL. I have verified the form ID. Thanks for your help.

function assignEditUrls() {
  var form = FormApp.openById('some id');
  var sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Form Responses 1');
  var data = sheet.getDataRange().getValues();
  var urlCol = 6;
  var responses = form.getResponses();
  var timestamps = [], urls = [], resultUrls = [];
  for (var i = 0; i < responses.length; i++) {
    timestamps.push(responses[i].getTimestamp().setMilliseconds(0));
    urls.push(responses[i].getEditResponseUrl());
  }
  for (var j = 1; j < data.length; j++) {
    resultUrls.push([data[j][0] ?
      urls[timestamps.indexOf(data[j][0].setMilliseconds(0))] : ''
    ]);
  }
  sheet.getRange(2, urlCol, resultUrls.length).setValues(resultUrls);
}

推荐答案

感谢鲁宾,我能够解决我的问题.在我的脚本中,我使用了不正确的表单ID.运行脚本以从Google表单获取编辑响应URL时,必须以特定表单的编辑模式查看编辑表单URL.从此编辑URL中提取表单ID,而不是从视图URL或共享URL等中提取.这是脚本以正确的权限访问正确表单的唯一方法.再次感谢鲁宾和所有其他提供帮助的人.

Thanks to Rubén, I was able to solve my problem. In my script I was using the incorrect Form ID. When running a script to obtain the edit response URLs from a Google Form you must view the edit form URL in the editing mode of your specific form. Extract the Form ID from this edit URL NOT the view URL or share URL etc. This is the only way your script will access the correct form with the correct permissions. Thanks again to Rubén and all others who assisted.

这篇关于重复出现的一般性错误消息Google Apps脚本的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆