+ Start a Discussion

Using metadata api to retrieve a list of all reports


I can not figure out how to retrieve a list of all reports from the metadata API and must be missing something simple.  If I setup a ListMetadataQuery and just set the type to "Report" I get nothing in return.  If I set the folder to null or "" I still get nothing in return.  If I set the Type to "Report" and set the folder to a folder with in the org then I get all the reports from that folder, which is expected.  What I need to know is, is there a way to get a list of folders for reports?  Or is there a way to list all the reports regardless of folder? Thanks in advance for any help.

I guess the easiest way of asking this is for the ListMetadataQuery, does the method setFolder have a wildcard character that will return any result from any folder?  I tried "*" and it didn't work


You have to specify a folder when querying an object that uses folders (http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_listmetadataquery.htm). The correct method, then, is to query for a list of folders (http://www.salesforce.com/us/developer/docs/api_meta/Content/meta_folder.htm?SearchType=Stem&Highlight=folders|folder|Folder|Folders) using retrieve() against the Folder object (which supports the wildcard *).

Max Friel.ax1251Max Friel.ax1251

Actually found an easier way to avoid running the retrieve.  You can run the listmetadata on ReportFolder and get a list of report folders.  Tacking the Folder ending on to any type that requires a folder will do the same with the exception of emailtemplates.  The folder type for that is just emailfolder.  Gotta love coding around those one of exceptions of the metadata api

Preeti LalwaniPreeti Lalwani
This is a very tricky problem to solve. However, Flosum (http://www.flosum.com) is a great tool which automates the salesforce metadata migration (http://www.flosum.com).
Sforce ChrisSforce Chris
Tricky is not the right word, more something like inconsistent instad.

Like Max suggested, listMetadata works well for describing the 4 folders. It works too for Email Template, but you need to specify EmailFolder (and not EmailTemplateFolder) ... You probably want to hardcode these values unfortunately since "describeMetadata" doesn't even provide any tip on how to name them (describeMetadata provides however information that these metadata are folders metadata). 
Vikash TiwaryVikash Tiwary
There is a workaround this to get all standard and custom report folders, reports and their datas. Here is the link explained in brief.

Hope this helps!!