Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Adding File to Folder in Google Drive Script

Google finally shut of the Docslist class and my script stopped running this week. Here is what my code was.

  var folder = DocsList.getFolderById('XXXXXXXXX');
  var document = DocsList.getFileById(newSS.getId());
  document.addtoFolder(folder);

So I was trying to switch over the use DriveApp instead. So here is the code that I have switched to.

  var folder = DriveApp.getFolderById('XXXXXXXXXX');
  var document = DriveApp.getFileById(newSS.getId());
  document.addFile(folder);

I'm getting an error "TypeError: Cannot find function addFile in object". I think I'm using the addFile wrong, but I'm not exactly sure what I'm doing wrong. Any help?

like image 758
Evan Morris Avatar asked Dec 25 '22 20:12

Evan Morris


1 Answers

Ok I figured it out. I had it backwards when using "addFile". I needed it to be

folder.addFile(document);

not

document.addFile(folder);
like image 93
Evan Morris Avatar answered Dec 27 '22 10:12

Evan Morris