function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Saravana Muthu 8Saravana Muthu 8 

Display Matrix Report Format in VF page with all the groupings

Hi,

Is there any way to display the matrix report with the same data and all the groupings in apex VF Page?

Please let me know if anybody have a sample code..

Thanks,
Sarav
NagendraNagendra (Salesforce Developers) 
Hi Saravana,

May I suggest you please check with below link from the forums community with a similar issue and a suggested workaround. Please let us know if this helps.

Kindly mark this as solved the information was helpful.

Thanks,
Nagendra
mukesh guptamukesh gupta
Hi Saravana,

Please use below code , we are using jsforce for report impliment
<apex:page>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.0/jquery.min.js"></script>
<script src="https://ajax.googleapis.com/ajax/libs/jqueryui/1.10.4/jquery-ui.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jsforce/1.5.0/jsforce.js"></script>
<script type="text/javascript">
j$ = jQuery.noConflict();
var divtable;
j$(document).ready(function() {
 var conn = new jsforce.Connection({accessToken: '{!$Api.Session_Id}'});
 var reportId;
 conn.query("SELECT DeveloperName,Id,Name FROM Report Where Format='Matrix' limit 1", function(err, result) 
 {
  if (err) { return console.error(err); }
  if(result.records.length ==0)
  {
   alert('Please Modify Query To Get the Reports');
  }
  reportId=result.records[0].Id;
  if(reportId != null)
  {
   var report = conn.analytics.report(reportId);
   report.execute({ details: true }, function(err, meta) 
   {
    if (err) { return console.error(err); }
    var columnnames=meta.reportMetadata["detailColumns"];
    var labelname="<table border='2'><tr><td>";
    var fieldvalues='';
    for (var i = 0; i < columnnames.length; i++) 
    { 
     labelname =labelname+meta.reportExtendedMetadata["detailColumnInfo"][columnnames[i]].label+'</td><td>';
    }
    labelname =labelname.slice(0, (labelname.length)-4) +'</tr>';
 
    // Now it can be used reliably with $.map()
    j$.each(meta.factMap, function(key, value) 
    {
     if(meta.factMap[key]["rows"].length >0)
     {
      for(var j=0;j<meta.factMap[key]["rows"].length;j++)
      {
       if(meta.factMap[key]["rows"][j]["dataCells"].length>0)
       {
        fieldvalues  = fieldvalues+ '<tr><td>';
        for(var i=0;i<meta.factMap[key]["rows"][j]["dataCells"].length;i++)
        {
         fieldvalues = fieldvalues +meta.factMap[key]["rows"][j]["dataCells"][i].label+'</td><td>';
        }
        fieldvalues  =fieldvalues.slice(0,fieldvalues.length-4);
        fieldvalues  =fieldvalues+ '</tr>';
       }
      }
     }
    });
    labelname  =labelname + fieldvalues +'</table>';
    j$("#totalrows").text('GrandTotal:'+meta.factMap["T!T"].aggregates[0].label);      
    j$("#responseMessage").html(labelname);
   });
  }
 });    
});
</script>
<div id="responseMessage"></div>
<div id="totalrows"></div>
</apex:page>


Please MARK AS BEST ANSWER!!!1

REgards
Mukesh
 
Saravana Muthu 8Saravana Muthu 8
I have already seen this but the code only get the table from the matrix but not all the groupings.

My requirement is to display the matrix report that i have in my org in a vf page with the all the details from that matrix report.

Thanks,
Saravana
Pavan UddarrajuPavan Uddarraju
Hi Saravan,
Have you found the solution for this?
 
Saravana Muthu 8Saravana Muthu 8
No, I don't find the solution for this as the client ignores this request at a later point.

Thanks,
Sarav