+ Start a Discussion
Firoz KamdarFiroz Kamdar 

How to display dashboard in visual force page

Ive looked through many pages (and bookmarked many) that show this and I've copied a very simple example, but it's not working.  I want to use an iframe to embed a salesforce lightning dashbaord on a visual force page.

I don't have much coding experience, but am confident I have enough knowledge to get this working.

My copied and edited code:

<apex:page standardController="Dashboard">

   <apex:iframe height="800px" width="600px" frameborder="true" rendered="true" scrolling="false"
	src="/01Z6A000000n28CUAQ?isdtp=nv" />

</apex:page>

The error message I get is that the sandbox domain refused to connect (researching this right now in case that's what the issue is).

Thanks!

Raj VakatiRaj Vakati
You can do like this 
 
<apex:page >
 <apex:iframe src="https://na12.salesforce.com/01ZU0000000NHAt" scrolling="true" id="theIframe"/>
</apex:page>

 
Firoz KamdarFiroz Kamdar
Thank you for the response! 

I tried that, but receive the same error "test.salesforce.com refused to connect."  My domain settings for this "Prevent login from https://test.salesforce.com" is unchecked.  I tried my companies sandbox domain in place of the cs10.salesforce.com, but same result.

Also, I'm doing this in a full Sandbox- in case that helps.
Ajay K DubediAjay K Dubedi
Hi Firoz,

If you want to add standard reports/dashboards to a VF page, you have to use an iframe for it.
You can set the source of the iframe to the URL of your report/dashboard.
 
<apex:page >
<apex:iframe src=”url of your report/dashboard” scrolling=”true” id=”theIframe”/>
</apex:page>

You can also follow this for example: 
https://vanityforce.wordpress.com/2013/02/03/two-methods-for-embedding-a-report-or-dashboard-chart-in-visualforce-or-standard-pagelayout/

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks,
Ajay Dubedi
Firoz KamdarFiroz Kamdar

Hi Ajay!  That doesn't work. My intial post is effectively the same thing, but even expanded to the full URL, it doesn't work..  The issue is that modern browsers have more security and X-Frame-Options are set to 'sameorigin.'  I asked about this in other posts, but no one could give me a helpful answer.

The link you referenced is from 2003- there have been too many changes in SF and browsers to use that information for someone with very light knowledge of programmatic development so it was not helpful to me, but thank you for posting it!

If you have any thoughts on where to look or how best to get around X-Frame-Options, I'm glad to try it out.