Code Guy
Code Guy

Reputation: 3198

Unable to get filename/foldername of team drive file using GAS

I have been trying to get the filename of a file/folder which is located in my team drive.

I have tried with

showAlert(DriveApp.getFolderById('0ANNqmMDkIgpzUk9PVA').getName());

Upvotes: 2

Views: 330

Answers (1)

Antoine Colson
Antoine Colson

Reputation: 656

Your code is good, so

  1. Check that you have the complete folder id. If you missed out some characters, it will not work.
  2. Check that you have at least viewing permission for the folder.

I successfully tested the following with a public folder:

SpreadsheetApp.getUi().alert(
  "Folder name: " + 
  DriveApp.getFolderById('16EbJb18MXxnDrbc0OsMbOk4CBxrT1upM').getName()
);

The alert popped up in an open Google Sheets page.Screenshot

You could also replace SpreadsheetApp.getUi().alert with Browser.msgBox

Upvotes: 1

Related Questions