You can retrieve report metadata to get information about a report and its report type.
Metadata includes information about fields that are used in the report for filters, groupings, detailed data, and summaries. You can use the metadata to do several things:
Find out what fields and values you can filter on in the report type.
Build custom chart visualizations by using the metadata information on fields, groupings, detailed data, and summaries.
Change filters in the report metadata when you run a report.
Use the ReportResults.getReportMetadata method to retrieve report metadata. You can then use the “get” methods on the ReportMetadata class to access metadata values.
Example
The following example retrieves metadata for a report.
1// Get the report ID2List<Report>reportList = [SELECT Id,DeveloperName FROM Report WHERE3 DeveloperName = 'Closed_Sales_This_Quarter' WITH USER_MODE];4String reportId = (String)reportList.get(0).get('Id');56// Run a report7Reports.ReportResults results = Reports.ReportManager.runReport(reportId);89// Get the report metadata10Reports.ReportMetadata rm = results.getReportMetadata();11System.debug('Name: ' + rm.getName());12System.debug('ID: ' + rm.getId());13System.debug('Currency code: ' + rm.getCurrencyCode());14System.debug('Developer name: ' + rm.getDeveloperName());1516// Get grouping info for first grouping17Reports.GroupingInfo gInfo = rm.getGroupingsDown()[0];18System.debug('Grouping name: ' + gInfo.getName());19System.debug('Grouping sort order: ' + gInfo.getSortOrder());20System.debug('Grouping date granularity: ' + gInfo.getDateGranularity());2122// Get aggregates23System.debug('First aggregate: ' + rm.getAggregates()[0]);24System.debug('Second aggregate: ' + rm.getAggregates()[1]);2526// Get detail columns27System.debug('Detail columns: ' + rm.getDetailColumns());2829// Get report format30System.debug('Report format: ' + rm.getReportFormat());