Find the location/folder of a report programmatically

apexreporting

Been spending a long time trying to get all the info about a report programmatically using apex. One place I'm stuck at is how to get the folder name where the report is located in, and also its permissions, which means what role do you need in order to access this report. Take a look at this image for example.

enter image description here

Basically I just need to get the name "Folder for Testing", since that is where my report is located in.

I've tried using several methods from metadata api, reportResults, reportExtendedMetadata, but still no luck. I thought I would be able to do it using a SOQL query, but I'm still working on that. Any help is much appreciated.

Thanks.

Best Answer

The Report object has a FolderName field that should contain what you are looking for. As for how to run the query, I personally would just run it through the Developer Console (it has a Query Editor tab). You can add fields you care about to your SELECT clause.

SELECT FolderName FROM Report WHERE DeveloperName = 'My_Report'