6

Trying to pull out a List of IDs from a matrix type report.

Example matrix report

I think I understand Tabular and Summary type reports but I am lost on Matrix type. Here is my code:

private List<Reports.ReportDetailRow> getRowsFromTabular(Reports.ReportResults results) {
    Reports.ReportFactWithDetails detailFact = (Reports.ReportFactWithDetails)results.getFactMap().get('T!T');
    return detailFact.getRows();
}

private List<Reports.ReportDetailRow> getRowsFromSummary(Reports.ReportResults results) {
    Reports.ReportFactWithDetails detailFact = (Reports.ReportFactWithDetails)results.getFactMap().get('0!T');
    return detailFact.getRows();
}

private List<Reports.ReportDetailRow> getRowsFromMatrix(Reports.ReportResults results) {
    Reports.ReportFactWithDetails detailFact = (Reports.ReportFactWithDetails)results.getFactMap().get('0!0');
    return detailFact.getRows();
}

Tabular and Summary work great, however results for Matrix are wrong.

I only get some of the IDs. enter image description here

I am sure that the problem is my use of the fact map selectors. However I can't figure out how to get them all. I have read and re-read the only document I can find from Salesforce about the Fact Map. Are there other tutorials or example of the Fact Map that I should understand?

3

This guide explains how to decode the fact map: https://resources.docs.salesforce.com/sfdc/pdf/salesforce_analytics_rest_api.pdf

Basically, the 0!0 you're getting is just the results of the first subtotal of the first grouping, and each grouping has subresults that you have to process to get the underlying data. Here's the relevant section of the docs:

Decoding the Fact Map for Matrix Reports

|improve this answer|||||

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.