ReferenceError: "DocsList" is not defined.

  • 4
  • Problem
  • Updated 3 years ago
  • Not a Problem
We started getting the following message on csvomport script for google docs sheet. Did something change ?

ReferenceError: "DocsList" is not defined.
Photo of Glenview Parks

Glenview Parks

  • 234 Points 100 badge 2x thumb

Posted 4 years ago

  • 4
Photo of Dan Goodman

Dan Goodman

  • 90 Points 75 badge 2x thumb
Just got this myself. It was working fine a week ago.
Photo of Courtney Felton

Courtney Felton

  • 84 Points 75 badge 2x thumb
if anyone figures this out please email me asap i will pay to fix brian at andrew auto transport .com
Photo of Dan Goodman

Dan Goodman

  • 90 Points 75 badge 2x thumb
Just change any reference to "DocsList" to "DriveApp"..everything else should stay the same.
Photo of Glenview Parks

Glenview Parks

  • 234 Points 100 badge 2x thumb
The importFromCSV just runs endlessly by changing to DriveApp  .. never returns data
Photo of Courtney Felton

Courtney Felton

  • 84 Points 75 badge 2x thumb
The solution is to change DocsList to DriveApp in your script. DocsList has been deprecated.
Photo of Glenview Parks

Glenview Parks

  • 234 Points 100 badge 2x thumb
were you able to get this to work ? I modified the importfromcsv script and it never returns data
Photo of Courtney Felton

Courtney Felton

  • 84 Points 75 badge 2x thumb
It works for me. Make sure you redeploy it after you make the changes. In the script editor, click Publish, then Deploy as Web App. 
Photo of Afroz Syed

Afroz Syed

  • 70 Points
I am getting the following error: "TypeError: Cannot find function getFolder in object Drive."
I tried everything as you mentioned. Changed the Folder name to the Folder ID. That didn't help either.
Photo of Glenview Parks

Glenview Parks

  • 234 Points 100 badge 2x thumb
See if this helps .. we had to change to the actual file ID (see below)

Photo of Carina Trinh

Carina Trinh

  • 70 Points
I still can't seem to get this to work...not sure how to change the file ID, I know nothing about Java scripts, have just tried to use the spreadsheet on google docs, changed DocsList to DriveApp, and now I'm a bit stuck
Hey folks i need professional help lol...can one of you contact me and I'll pay you to fix? 212-729-0192 or brian@andrewautotransport.com
Photo of Blake Freeman

Blake Freeman, Official Rep

  • 36,116 Points 20k badge 2x thumb
Hello everyone,

What is the situation here? Where are you seeing this ReferenceError? Is this from one of our widgets/gadgets, or is it something custom built?
not from a widget/gadget but a google drive spreadsheet (which the spreadsheet widget references) that is running some scripts.  it's the function importFromCSV() from this website https://developers.google.com/apps-script/articles/docslist_tutorial?csw=1 that has a docslist class call in that google has deprecated.  replacing the docslist class call with Driveapp gives a never ending script (it times out after a minute or 2). 
Photo of Glenview Parks

Glenview Parks

  • 234 Points 100 badge 2x thumb
Same here, even after publishing 
Photo of Blake Freeman

Blake Freeman, Official Rep

  • 36,116 Points 20k badge 2x thumb
You will need to contact google about this issue.
Photo of Glenview Parks

Glenview Parks

  • 234 Points 100 badge 2x thumb
Thanks .. I'm on hold with them now
Photo of ZD

ZD

  • 62 Points
Changing DocsList to DriveApp didn't work here. Can anyone help? Here is the code:

function gettimesheets() {
  var ss = SpreadsheetApp.getActiveSpreadsheet();
  var searchTerm = "Time Sheet";
  var sheet = ss.getSheetByName("File:Key");
  
  // Set up the spreadsheet to display the results
  var headers = [["File Name", "Key"]];
  sheet.clear();
  sheet.getRange("A1:B1").setValues(headers);
  // Search the files in the user's Docs List for the search term
  var files = DocsList.find(searchTerm);
  // Loop through the results and display the file name, and key
  for (var i = 0; i < files.length; i++) {
    sheet.getRange(i+2, 1, 1, 1).setValue(files[i].getName());
    sheet.getRange(i+2, 2, 1, 1).setValue(files[i].getId());
    
  }
}
Photo of Reger Group

Reger Group

  • 60 Points
Thanks so much for everyone who contributed here:

The following steps led me to success!
  1. Opened the script.. then..
  2. => Edit
  3. => Find and Replace
  4. Find = "DocsList"
  5. Replace = "DriveApp"
  6. => Replace all
  7. Then save the script.
Photo of Carina Trinh

Carina Trinh

  • 70 Points
Do you get an error TypeError: Cannot find function getFolder in object Drive ? Then if you change getFolder, do you get an error: Cannot find method getFolders(string).?