+ Start a Discussion
PranaliPranali 

How to retrieve Report and Report Type details for use in apex.

Hi,
I need to extract information about Reports and ReportType and use it in apex. The Report object thats available in version 20 has fields like description , DeveloperName , lastRunDate etc. But i need other information like aggregates , chart , colorRanges , columns , reportType , groupingsAcross etc. And i also need to extract the report type details like the BaseObject , category , join , columns etc. These are available through the Metadata API but the Metadata API cannot be used from within Apex. Is there any way i can retrieve this report information in apex?

b-Forceb-Force

Have you try out Metadata API to retrive report and Report type details ?

You can retrive this details using metadata API

 

Thanks,

bala

Ispita_NavatarIspita_Navatar

I don't think we can access the functions exposed by metadata API in Apex.

A work-around would be probably to have a custom object for storing the necessary information for your specific requirement and then access the same in Apex.

Now comes the next part how to populate the custom object with the required information about report. For this one can build a third party tool in Dot net and using metadata WSDL and partner WSDL retereive the information about reports and report types and store them in the custom object thus designed. Now within salesforce this information can be consumed in Apex.

Though  a torturous way of achieving your requirement , still you can give it a try.

 

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved.

hisrinuhisrinu

Here are the steps to retrieve the report information from Apex.

 

1. Create a custom report type for reports

2. Create a report and get all the reports and required fields from that report which includes the report's report type also

3. Create a custom object which holds these fields.

4. You can make use of analytic snapshot to populate these report values into the custom object

5. Finally you can query this information from Apex.

 

I know it is a bit tedious but I haven't seen any other approach, let me know if you got any other good approach