getFolderById not working

2,653 views
Skip to first unread message

Roy Brophy

unread,
Aug 15, 2022, 1:39:59 PM8/15/22
to Google Apps Script Community
Hi All,

My first time posting here - so I hope I get it right!

I am getting a...

" Exception: Unexpected error while getting the method or property getFolderById on object DriveApp  "

error when trying to run some pretty basic code...

"use strict"; 
//********************************************************
// TEST createSpreadsheet 
// Creates a spreadsheet in My Drive and then moves it
// to the targetFolder as definned by folder ID - idFolder
//********************************************************
function TESTcreateSpreadsheet(){

  // Id of the destination folder 
  var idFolder = "1LB49y6bMv93ja08EnoV4oPn59IwuJjDz"

  // get the destination folder
  var targetFolder = DriveApp.getFolderById("idFolder")

  // Create the spreadsheet in the root My Drive
  var ssTEST = SpreadsheetApp.create("TEST_Spreadsheet")

  // Move the spreadsheet into the destination folder
  DriveApp.getFileById(ssTEST.getId()).moveTo(targetFolder);

}

The problem lies with the  DriveApp.getFolderById("idFolder") - The folder id is correct...

DriveApp error 1.JPG

I have google this but just can see what I'm doing wrong!

Screen grab of the error.,..

DriveApp error 2.JPG

Thanks,
Roy

Roy Brophy

unread,
Aug 15, 2022, 1:49:13 PM8/15/22
to Google Apps Script Community
Ughhhh.... Idiot me... sorry for wasting your time!

Don't need the quotes... What a newbie error!!!!!!!!!!

Roy

Reply all
Reply to author
Forward
0 new messages