• Client Services
  • NEWBIE
  • 0 Points
  • Member since 2014

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 2
    Questions
  • 0
    Replies
I am using the new analytics API to call a salesforce report. The report is of the matrix format and has a multiple columns, each with 2 rows of data. when calling the report using the new analytics API, only the first row of data is posted. Is there a way to get both rows of data? Below is the code that is pulling the data values: 

function getData( jsonData ) {
    var chartData = new google.visualization.DataTable();
    chartData.addColumn( "string", "Stage" );

    $.each( jsonData.groupingsDown.groupings, function( index, values ) {
      chartData.addColumn( "number", values.label );
    });

    $.each( jsonData.groupingsAcross.groupings, function( columnIndex, columnValues ) {

      var values = [];
      values.push( columnValues.label );

      $.each( jsonData.groupingsDown.groupings, function( rowIndex, rowValues ) {

        var cellIndex = rowValues.key + "!" + columnValues.key;
        values.push( jsonData.factMap[ cellIndex ].aggregates[ 0 ].value );

      });

      chartData.addRow(values);

    });

    return chartData;
   
  }


Hi All--

I'm new to Salesforce and am trying to build a VF page that will display 25 records and 5 Columns using the analytics api. I have gotten the following code to properly display the 25 records, however it only displays 2 columns (Property Name and Record Count). I have tried building the underlying report in matrix, summary, and tabular format...each with the same result. I believe there is something in the code that is limiting the display to 2 columns, but I can't figure it out. The columns I need displayed are all custom. 

Thanks in advance for your help! You don't know how amazing it will be if I get this down :)

<apex:page sidebar="false" showHeader="false">
    <apex:includeScript value="https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js" />
    <apex:includeScript value="https://www.google.com/jsapi" />
    <script>
        google.load('visualization', '1', {
            'packages': ['table']
        });
        $(document).ready(function () {
            $.ajax('/services/data/v29.0/analytics/reports/{!$CurrentPage.parameters.reportId}', {
                beforeSend: function (xhr) {
                    xhr.setRequestHeader('Authorization', 'Bearer {!$Api.Session_ID}');
                },
                success: function (reportResult) {
                    var chartPoints = [];
                    $.each(reportResult.groupingsDown.groupings, function (index, value) {
                        chartPoints.push([value.label, reportResult.factMap[value.key + "!T"].aggregates[0].value]);
                    });
                    var options = {};
                    var labels = [
                        [
                        reportResult.reportExtendedMetadata.groupingColumnInfo[reportResult.reportMetadata.groupingsDown[0].name].label,
                        reportResult.reportExtendedMetadata.aggregateColumnInfo[reportResult.reportMetadata.aggregates[0]].label
                        ]
                    ];
                    var myData = google.visualization.arrayToDataTable(labels.concat(chartPoints));
                    var table = new google.visualization.Table(document.getElementById('table'));
                    table.draw(myData, {showRowNumber: false});
                }
            });
        });
    </script>
    <div id="table" style="height: 400px;width:400px;"></div>
</apex:page>