+ Start a Discussion
Andy Freeston_LarterAndy Freeston_Larter 

Using the Report API with reports containing two groups

I am trying to read a Salesforce Report using the Apex API. I cannot find a way to decode the fact map when I have two groupings in the report.
My report returns a list of contacts and contains two groups, Country and Salutation. The API function “getGroupingsDown” returns a single list of values that correspond to the Country values. There doesn’t appear to be a function to return the second grouping values, or a list of GroupingValues for each group.
Reports.ReportResults results = Reports.ReportManager.runReport(reportId, true);
for ( Reports.GroupingValue groupingVal : results.getGroupingsDown().getGroupings() )
    System.debug('GroupingsDown Key:' + groupingVal.getKey() + ' Label:' + groupingVal.getLabel() + ' Value:' + groupingVal.getValue() );
This returns:
GroupingsDown Key:0 Label:- Value:null
GroupingsDown Key:1 Label:France Value:France
GroupingsDown Key:2 Label:US Value:US
GroupingsDown Key:3 Label:USA Value:USA
Is there another function I should be calling or another method to return the Salutation values for the second group?
Many thanks.