+ Start a Discussion
dmchengdmcheng 

Get list of reports in a folder

This is an informational posting since I couldn't find it documented anywhere:

 

If a report is in a folder, the OwnerID of the report corresponds to the ID of the folder object, so you can query a report folder's contents like this:

 

 

folder[] ff = [select id from folder where developername = 'Community_Inventory_Tool_Reports'];
id fid = (ff.isEmpty()) ? null : ff[0].id;
report[] rpts = [select id, name, description from report where ownerid = : fid and ownerid != null order by name];
return (rpts.isEmpty() == null) ? null : rpts; 

 

 

 

 

sfdcfoxsfdcfox

Awesome. You don't need the ownerid != null since you're already specifying ownerid = :fid, though. It's great to see that Report has finally been exposed to the API (as of version 20.0). That used to be a terribly frustrating time when reports were not visible through the API, but instead only through some generic XML writer that was hidden at a particular URL for Connect for Microsoft Office functionality.

tggagnetggagne

We've been digging around for this information for a few days.  Actually, we first started looking for it weeks ago.

 

Thanks!

 

How can I +1 this?

dmchengdmcheng

Glad this was helpful.  You can't +1 or give ratings in this forum system, but thanks for the consideration.

 

Cheers

David

sfdcsushilsfdcsushil
Thanks David, this was very helpful.