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
BrittanyBrittany 

Dashboards in Visualforce page

Hi,

 

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?

 

SFFSFF

You can put VF pages on a dashboard:

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_quick_start_advanced_dashboard_components.htm

 

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

 

http://www.salesforce.com/us/developer/docs/pages/Content/pages_charting.htm

 

Hope this helps,

kiranmutturukiranmutturu

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...

BrittanyBrittany

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="{!opp.name}"/>
            <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:pageBlockTable>
    </apex:pageBlock>
</apex:page>

 

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]));
               setUpcomingRenewalOpps.setPageSize(5);
            }
            return setUpcomingRenewalOpps;
        }
        set;
    }
    
    public List<Opportunity> getOpportunities() {
            return (List<Opportunity>) setUpcomingRenewalOpps.getRecords();
    }
}

 

Test Class:

 

 

@isTest
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 = Date.today();
        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;
    }
}