简体   繁体   English

Google Apps脚本权限问题

[英]Google apps script permission issues

I have a google sheet with a form that I have edit access to. 我有一个Google表格,该表格具有我可以对其进行编辑的权限。 I am trying to write a GAS to allow prepopulating this form based on a users previous response. 我正在尝试编写GAS,以允许根据用户先前的响应来预先填充此表格。 I can read/write the form and the spreadsheet with no issues. 我可以毫无问题地读/写表格和电子表格。 The problem comes from attempting to run the following code which I copied from a Mogsdad ( big fan )post. 问题来自尝试运行以下代码,这些代码是我从Mogsdad(大粉丝)帖子中复制的。

function betterBuildUrls() {
 var ss = SpreadsheetApp.getActive();
 var sheet = ss.getSheetByName("Form Responses 1");
 var data = ss.getDataRange().getValues();  // Data for pre-fill
 var formUrl = ss.getFormUrl();             // Use form attached to sheet
 var form = FormApp.openByUrl(formUrl);
 var items = form.getItems();
 // remainder truncatted

The issue occurs with the line 该行出现问题

var form = FormApp.openByUrl(formUrl);

and the error I am receiving is: 我收到的错误是:

No item with the given ID could be found, or you do not have permission to access it. (line 19, file "Code")

I confirmed that I have edit permission in the sheet and even put together a logger to pull the values from the sheet. 我确认我具有工作表中的编辑权限,甚至还组合了一个记录器以从工作表中提取值。

[14-11-07 13:15:55:925 EST] XXXX@example.com
[14-11-07 13:15:55:926 EST] [XXXX@example.com, XXXX@example.com, XXXX@example.com,
ThisOneIsME@example.com, xxxx@example.com]

Do I need to be the owner before I can build scripts for it? 在为其创建脚本之前,需要成为所有者吗? I have removed all my other google accounts, restarted chrome,restarted the computer. 我删除了所有其他Google帐户,重新启动了chrome,重新启动了计算机。

Is this just google being weird as usual? 这只是谷歌像往常一样奇怪吗?

Any help would be much appreciated. 任何帮助将非常感激。

Without seeing the form and the environment that you have, it's tough to say what the root cause could be here, but the short answer is no, you do not need to be the owner of the script to run this function. 在不了解您所拥有的形式和环境的情况下,很难说出根本原因是什么,但是简短的答案是“不”,您无需成为脚本的所有者即可运行此功能。

I've just tested the code you provided on a form that I only have edit access to, and it runs fine. 我刚刚在仅具有编辑权限的表单上测试了您提供的代码,并且运行良好。 I also tried to break it and I couldn't. 我也试图打破它,但是我没有。

I suspect the problem is either with the remainder of your code, or with the form. 我怀疑问题出在代码的其余部分还是表单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM