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
Vaibhav Jain 13Vaibhav Jain 13 

Embedding Report(Without any Chart) on a Visualforce page

Hie
I want to embed or to display a report on my VF page. Report doesn't contain any chart.
I used the tag<analytics reportchart reportID/> but it shows the error that The report chart is unavailable because the report's format is not summary or matrix. 
I also tried to use <apex iframe tag> to embed report on my page but it is also not displaying anything.

Could you tell me how I can display a report(summary or tabular or matrix) on a VF page?

Thanks in advance.

 
Gaurav KheterpalGaurav Kheterpal
This will happen if you do not have a report which is either summary or matrix. You can use this method to find out all reports
 
public List<SelectOption> retrieveAvailableReports() {
    List<SelectOption> reptOpts = new List<SelectOption>();
    for (Report r : [
         Select Id, Name
         From Report
         Where Format In ('Summary','Matrix')
         Order By Name
    ]) {
        reptOpts.add(new SelectOption(r.Id, r.Name));
    }
    return reptOpts;
}

Make sure you have a valid summary or matrix report. You can follow this (http://peterknolle.com/apex-analytics-api-and-report-chart-component/) detailed tutorial on how to include such reports in your pages.

If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others and improve the overall quality of Discussion Forums.

Gaurav Kheterpal
Certified Force.com Developer| Salesforce Mobile Evangelist| Developer Forums Moderator| Dreamforce Speaker


 
Dave CortrightDave Cortright
Ricardo DiazRicardo Diaz
Hi Dave, 

I'm trying to replicate your solution in my code. Currently, I'm getting Error: Unknown property 'Contact.id' referenced in Bid_List.

Could you perhaps provide some insight into what Contact.id is calling in? I am trying to embed a Tabular Report based off Opportunity data into a VF page. Even when I replace that part with Opportunity.id I get the same error.
Dave CortrightDave Cortright
My page declaration is this:
<apex:page standardController="Contact" sidebar="false" showHeader="false">
Maybe you're not setting a standardController?
Ricardo DiazRicardo Diaz

Dave, you were correct. (I'm kinda new at VF)

I have added the Opportunity controller into my code (since the report I am trying to run is based off Opportunity data). However, the report is also a custom report type labeled "Project." Does this make a difference? When previewing the page, only the pageblocksection area comes up.

I've attached my code!
 
<apex:page standardController="Opportunity">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js"></script>

    <apex:pageBlock title="Bid List1" mode="edit">

        <apex:pageBlockSection title="Today's Bids" id="TodaysBids" columns="1">
            
        </apex:pageBlockSection>

    </apex:pageBlock>
    
    <script language="JavaScript">
        $('[id$="MyReport"] > .pbSubsection > .detailList').load('/00O61000003sxh9?pv0={!Opportunity.id}&isdtp=nv table.reportTable.matrixReportTable');
    </script>

</apex:page>


 
 
Ricardo DiazRicardo Diaz
I made a mistake in mentioning this...Opportunities has been renamed to "Projects". It isn't a custom report type.

When defining the controller, would it remain as Opportunity? Attempting to define the controller as Project, an error is shown.
DixitDixit
Your standardcontroller should be referenced as your API object's name, which should be "opportunities" at the moment, that's why you get an error when renaming to "Projects" but not when placing "Opportunity", check yout object's API name and provide that one.

Check if your report is a summary or matrix type or create your own chart with the documentation below: 
https://developer.salesforce.com/docs/atlas.en-us.pages.meta/pages/pages_charting_overview_simple_example.htm 

or as an example, i made this one in a visualforce page:
public Data[] getData() {
    
    return new Data[] {
        new Data(simulacion.name, simulacion.Importe_Total_Simulacion__c),
        new Data(simulacion.Plantilla_Relacionada__r.name, simulacion.plantilla_relacionada__r.Importe_Total_MXN__c)
        };
        
    }
    
     // Wrapper class
    public class Data {
        public String name { get; set; }
        public decimal data1 { get; set; }
        
        public Data(String name, decimal data1) {
            this.name = name;
            this.data1 = data1;
        }
    }

Where "simulacion" is a variable of type: simulacion__c which refers a custom object i made. 

and my VF page:
<apex:chart data="{!data}" height="300" width="400">
    <apex:axis type="Numeric" position="left" title="Total MXN" fields="data1"/>
    <apex:axis type="Category" position="bottom" fields="name" />        
    <apex:barSeries orientation="vertical" axis="left"
        xField="name" yField="data1" title="Simulacion" colorSet="#37241E,#94B3C8,#4D4E24,#BD8025,#816A4A,#F0E68C"/>
</apex:chart>

at the moment, when displaying a chart into a visualforce with SLDS the colors are not displaying, but when using normal visualforce does.