3
votes

I have a Google Script attached to a Form that does a whole bunch of different things, but ultimately creates a couple of copies of a sheet.

The process has been working great for months, but recently I have been getting the following error when using the File.makeCopy method (https://developers.google.com/apps-script/reference/drive/file#makecopyname-destination)

 function createTest()
{
  var templateFile = DriveApp.getFileById("ID");
  templateFile.makeCopy("NAME", DriveApp.getFoldersByName("FOLDERNAME").next())
}

Access Denied: Drive App (on the templateFile.makeCopy line)

I have ensured that the Drive scope is added and there are no GSuite settings that could cause this(such as the DriveApp being disabled).

I cannot find a good answer as to why this would have stopped working over the last few days. Any ideas are welcome!

1
What scope is added to the appsscript.json (manifest) file? - Alan Wells
1.What's the name? 2. What's the destination? 3.Do you have access to the destination? 4.Do you have enough free space in Drive? 5.How many sheets have you created/day? 6. Can you manually make a copy (1)with the same name and (2)in the same destination? - TheMaster
Scope: googleapis.com/auth/drive (among others). - Name/Destination: No name or destination changes have made this work yet. I have full access to the destination. - Manual copy works fine with the name and destination copied from the method. - Drive space isnt an issue, deleted everything from the destination and issue persists. - Sheets created this way, ~10. - Ty Rozak
Although I'm not sure whether this leads to the direct solution, can you provide the latest script with the issue? Of course, please remove the personal information from it. By the way, you can retrieve the filename and fileId of the file using DriveApp? - Tanaike
Have you tried running a simple syntax with driveapp in another script? is this producing the same error? - shabnam bharmal

1 Answers

2
votes

I don't know if this is still relevant, but as I had the exact same issue without an answer, I happened to use a wrong file id. So if you run this code, be sure to double check the accessed id(s).

Also: make sure the folder iterator in DriveApp.getFoldersByName("FOLDERNAME").next() actually has a next, thus there is a folder called "FOLDERNAME" inside your root folder. Else you would make a call on an undefined object.