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
pcave_jrpcave_jr 

Is report metadata available via Apex?

Is it possible to read the metadata of a report in Apex. I'm interested in being able to get the fields and conditions that have been assigned to a report programitcally.

 

Thanks,

Phillip

Avi646Avi646

yes the report metadata is available via metadata api. You can get the filter criteria and many other things from the extracted metadata.

pcave_jrpcave_jr

Thanks. But isn't the metadata api for external applications to consume? How would I access the metadata api from within an Apex class?

sfdcfoxsfdcfox

The correct answer here is "no." You can not access the Metadata API through Apex Code, primarily because the API is asynchronous, while Apex Code is synchronous, and it returns a compressed file, and Apex Code is not well suited to handling binary data. There's too many limitations in Apex Code to even attempt this. Your best choice would be to request and unpack the data using JavaScript in a Visualforce page. Even that would not be a trivial task, but it would be conceivable, at least.

Avi646Avi646

sorry didnt noticed the apex part... :P