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

Dashboards in Visualforce page



I am trying to find out if it is possible to show a dashboard, that I have already created on a dashboard page, to show up in a Visualforce page.


Does anyone know if this is possible?



You can put VF pages on a dashboard:


but you can't put dashboards on a VF page. Sorry. What you can do it create VF charts that look like dashboards:


Hope this helps,


1.You can't get the dashboards that you arer created using native dashboards creation page...but there is way to get the native dashboad view in to vf pages with in iframes but that will not suggestable


2. Visualforce charting is GA now so you can generate the same or more robust charts with this concept but invloves little bit coding ......



3. if you are not interested to go with VF charting then you can go with external API's like google charts , HighCharts etc...


I was able to make the table that I was looking for on the Visualforce page in my sandbox. However, now I am trying to figure how I move it over to my production site. I created the test code for it which has no errors but when I run the test it brings back 0% coverage for the one class that I need to get coverage for.


Thanks for the help!


Below is the Visualforce Page:


<apex:page sidebar="false" showHeader="false" controller="UpcomingRenewals">
    <apex:pageBlock >
        <apex:pageBlockTable value="{!Opportunities}" var="opp">
            <apex:column headervalue="Contract Start Date" value="{!opp.contract_start_date__c}"/>
            <apex:column headerValue="Oppty Name" value="{!}"/>
            <apex:column headerValue="HLS-FYCV" value="{!opp.HLS_FYCV__c}"/>
            <apex:column headerValue="Expected Renewal HLS-FYCV" value="{!opp.expected_renewal_hls_fycv__c}"/>


Apex Controller for the Visualforce Page: (it queries only renewal opportunities whos contract start date is within this month)

public class UpcomingRenewals{
    // Get a set of all Renewal Opportunities 
    public ApexPages.StandardSetController setUpcomingRenewalOpps {
       get {
            if(setUpcomingRenewalOpps == null) {
               setUpcomingRenewalOpps = new ApexPages.StandardSetController(Database.getQueryLocator(
                   [SELECT contract_start_date__c, name, HLS_FYCV__c, expected_renewal_hls_fycv__c FROM Opportunity 
                   WHERE Oppty_Record_Type__c ='Active_Client_Renewal' AND contract_start_date__c= THIS_MONTH
                   ORDER BY contract_start_date__c]));
            return setUpcomingRenewalOpps;
    public List<Opportunity> getOpportunities() {
            return (List<Opportunity>) setUpcomingRenewalOpps.getRecords();


Test Class:



public class TestUpcomingRenewals {
    static testMethod void testRenewalsSuccess() {
        RecordType[] RecID = [Select id from RecordType where name = 'Active Client : Renewal'];
        Opportunity opp = new Opportunity();
        opp.Name = 'Upcoming Renewals Process test';
        opp.StageName = 'Propose';
        opp.Product_Line__c = 'XP Pro';
        opp.CloseDate =;
        opp.LeadSource = 'Other';
        opp.RecordTypeId = RecID[0].Id;
        opp.contract_start_date__c = Date.Today();
        opp.expected_renewal_hls_fycv__c = 60000;
        // insert the new opp
        insert opp;