You need to sign in to do that
Don't have an account?
Abhi Mehta
Fetching Report Data In Apex Class Error
// Get the report ID
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where DeveloperName = 'Count_Of_Cases_Related_To_Particular_Acc'];
String reportId = (String)reportList.get(0).get('ID');
// Run a report synchronously
Reports.reportResults results = Reports.ReportManager.runReport('00O3D000000f6T3', true);
// Get the first down-grouping in the report
Reports.Dimension dim = results.getGroupingsDown();
Reports.GroupingValue groupingVal = dim.getGroupings()[0];
System.debug('Key: ' + groupingVal.getKey());
System.debug('Label: ' + groupingVal.getLabel());
System.debug('Value: ' + groupingVal.getValue());
// Construct a fact map key, using the grouping key value
String factMapKey = groupingVal.getKey() + '!T';
// Get the fact map from the report results
Reports.ReportFactWithDetails factDetails =
(Reports.ReportFactWithDetails)results.getFactMap().get(factMapKey);
// Get the first summary amount from the fact map
Reports.SummaryValue sumVal = factDetails.getAggregates()[0];
System.debug('Summary Value: ' + sumVal.getLabel());
// Get the field value from the first data cell of the first row of the report
list<Reports.ReportDetailRow> detailRow = factDetails.getRows();
System.debug('########### detailRow'+detailRow);
The List(detailRow) is not fetching any data. Everything is working fine.
List <Report> reportList = [SELECT Id,DeveloperName FROM Report where DeveloperName = 'Count_Of_Cases_Related_To_Particular_Acc'];
String reportId = (String)reportList.get(0).get('ID');
// Run a report synchronously
Reports.reportResults results = Reports.ReportManager.runReport('00O3D000000f6T3', true);
// Get the first down-grouping in the report
Reports.Dimension dim = results.getGroupingsDown();
Reports.GroupingValue groupingVal = dim.getGroupings()[0];
System.debug('Key: ' + groupingVal.getKey());
System.debug('Label: ' + groupingVal.getLabel());
System.debug('Value: ' + groupingVal.getValue());
// Construct a fact map key, using the grouping key value
String factMapKey = groupingVal.getKey() + '!T';
// Get the fact map from the report results
Reports.ReportFactWithDetails factDetails =
(Reports.ReportFactWithDetails)results.getFactMap().get(factMapKey);
// Get the first summary amount from the fact map
Reports.SummaryValue sumVal = factDetails.getAggregates()[0];
System.debug('Summary Value: ' + sumVal.getLabel());
// Get the field value from the first data cell of the first row of the report
list<Reports.ReportDetailRow> detailRow = factDetails.getRows();
System.debug('########### detailRow'+detailRow);
The List(detailRow) is not fetching any data. Everything is working fine.