function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
arytenaryten 

Replicate Report query inside Apex code

 

Hi,
 
I have read that Salesforce expose some fields about Report in the Metadata API. How can i access those fields in an Apex class?
 
Example: i have created a Report (called "Rep01") and i want to retrieve its fields or filters. I supposed to do like that:

 

 

 

List<Report> reps = [SELECT Id,Name FROM Report WHERE Name =: 'Rep01' ];
Report r = reps.get(0);

String repField = r.columns[0].field; // ** ERROR ** : Invalid field columns for SObject Report

 

 

 

Since i get the error.. what is the correct way to access those fields listed in the API here ? Please help..

 

Thanx in advance for the answer...

 

mtbclimbermtbclimber

The information you want to access in Apex is not exposed in the API on which Apex sits.  It's a great idea though. There are a number of report/dashboard API related ideas already posted. Not sure if any of them match your goal directly though this one might be close:

 

https://sites.secure.force.com/success/ideaView?id=08730000000Jfw2AAC