[SalesForce] How to find the folder of a salesforce report

Is there any relationship between salesforce Reports and Folder objects, to determine the content of the folder or find the residing folder of a particular report ?

Best Answer

The Report object does not have a FolderId field like Dashboard, Document and EmailTemplate objects. But as you can see from this their does exist a child relationship between Folder and Report, which is in fact determined by the OwnerId of the Report.

Thus once you know the folder Id you can query for reports that are contained within it.

SELECT Id, DeveloperName,Name,Type FROM Folder 
  WHERE Name = 'My Test Folder' And
              Type = 'Report' 

Then query by OwernId with the Folder Id returned e.g.

SELECT Description,DeveloperName FROM Report WHERE OwnerId = '00lG0000000TwG5IAK'

enter image description here