0
votes

I'm trying to save all the responses of a Google Form file (with an onSumbmit(e) function, based on a trigger) to a newly created spreadsheet, based on a template. Unfortunately my script stops working at this point:

var ID = "I put here the ID of the file template";
  
  var ss = SpreadsheetApp.open(DriveApp.getFileById(ID)); <-- Here it stopped

  ss.copy(name+"_"+date);

I really don't know why, but the scripts seems unable to open the template file and make a copy. I've also tried with a getFileByUrl, SpreadsheetApp.openById(ID) and SpreadsheetApp.openByUrl(URL), but nothing change!

I receive this error: You do not have permission to call openById

I've read here that maybe it's a policy change of Google but it's over 2 years ago. Maybe I'm doing something wrong?

Thanks to all!

1
Why don't you use SpreadsheetApp.openById(ID)? Documentation - Casper
If you know the file ID, then use the openById(id) method of the SpreadsheetApp class. SpreadsheetApp.openById(id) - Alan Wells
Already tried also that way. openByID or Url doesn't work, the script simply stop working. :( - Vito Alessandro I.
Are you the owner of the spreadsheet file? - Anton Dementiev
You need to delete the existing "On Form" submit trigger, and add a new one. Apps Script has a long history of triggers silently failing. And I guess no one at Google is smart enough to figure out why. - Alan Wells

1 Answers

0
votes

Ok, I've done!

My script has this at the beginning:

/**
* @OnlyCurrentDoc
*/

And I misunderstand its meaning! I didn't understand that this code forces the script to work only on the active form. Without this code it works perfectly! Thanks to everyone!!!