简体   繁体   中英

Google apps script permission issues

I have a google sheet with a form that I have edit access to. I am trying to write a GAS to allow prepopulating this form based on a users previous response. 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.

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.

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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