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
Apipoj PiasakApipoj Piasak 

Page redirect to dashboard source page when using iFrame

Hi all,

I have created the visualforce page to embed the dashboard in the home page. It works perfectly fine until yesterday. The home page redirect to the dashboard page without sidebar, header. To fix this I have to remove the iframe from the visualforce page.
 
<apex:iframe src="/01Z90000000MXp0?isdtp=vw" scrolling="true" height="1000px" width="100%" />

Any ideas how to solve this and make it works again?

cheers 
Best Answer chosen by Apipoj Piasak
subbareddysubbareddy
Hi Pramitha,

try the below code, add "outputPanel"

<apex:page showheader="false" sidebar="false">
<apex:outputPanel id="SalesfunnelDashboard" >
     <script>
      location.href="https://cs13.salesforce.com/01Z50000000xcKR?isdtp=vw";
     </script>
     </apex:outputPanel>
</apex:page>

All Answers

Siddharth PrakashSiddharth Prakash
Even i am facing this issue !!!
kynchiiin2kynchiiin2
I am having the problem! Dashboard just opens to it's own page and now way to get to home page. Need solution ASAP!
Siddharth PrakashSiddharth Prakash
Hi Guys,

We were able to solve it by using self.location.href = "complete URL" in the apex page. Kindly let me know if you need any help.

Regards
Siddharth
kynchiiin2kynchiiin2
Thanks Siddharth - would you be able to paste in the sample code of how you solved it? I am somewhat new to this so any help would be appreciated. Thank you!
Siddharth PrakashSiddharth Prakash
if(sw == "Admin")
{
location.href = "https://naX.salesforce.com/01Z40000000MXOu?isdtp=vw"; } 
 
Tim MulveyTim Mulvey
Siddharth,

I am having the same issue.  Below is my code for my home page dashboard.  Can you help me with what I am doing wrong?

<apex:page showheader="false" sidebar="false">
<apex:iframe src="/01Z/o?isdtp=nv" scrolling="true" height="495px" width="100%"/>
if(sw=="Admin")
{
location.href="https://naX.salesforce.com/01Z/o?isdtp=nv";} 
</apex:page>
Siddharth PrakashSiddharth Prakash
Hi Tim,

We cant use iframe.

<apex:page showheader="false" sidebar="false">

if(sw=="Admin")
{
location.href="https://naX.salesforce.com/dashboardID?isdtp=vw";} 

</apex:page>

 
Tim MulveyTim Mulvey
Thanks Siddharth.  That fixed the redirection but I think my dashboard href url is incorrect.  Where do I find the correct url?
Siddharth PrakashSiddharth Prakash
Hi Tim,

Once you open a dashboard , just copy the complete URL present in the browser and put the same inside commas 
Tim MulveyTim Mulvey
Thanks for all your help Siddharth.  When I click on dashboards I am directed to this url: https://na11.salesforce.com/01ZG0000000UPEO.  I add that to my code as you can see below but still do not see the dashboard on the home page.  I only see the outlined box with the if statement in it.

<apex:page showheader="false" sidebar="false">

if(sw=="Admin")
{
location.href="https://na11.salesforce.com/01ZG0000000UPEO";} 

</apex:page>
 
Siddharth PrakashSiddharth Prakash
<apex:page showheader="false" sidebar="false">
        <script>
        location.href="https://na11.salesforce.com/01ZG0000000UPEO;
        </script>
</apex:page>

 
Tim MulveyTim Mulvey
That worked.  Thanks for all the help Siddharth I appreciate it.
subbareddysubbareddy
Hi,

Below is my code and added to home page component, still it is redirecting to dashboards tab. am i missing anything in my code?

<apex:page showheader="false" sidebar="false">
     <script>
      location.href="https://cs2.salesforce.com/01Z50000000wDb4";
     </script>
</apex:page>
Siddharth PrakashSiddharth Prakash
Add  "?isdtp=vw"
location.href="https://cs2.salesforce.com/01Z50000000wDb4?isdtp=vw";
subbareddysubbareddy
Hi Siddarth, after adding isdtp=vw also redirecting to dashboards tab. Thanks a lot for your guidance.
subbareddysubbareddy
It is working perfectly in production, but for unknown reasons it is not working in sandbox.
Siddharth we appreciate your help.
Pramitha Nair 9Pramitha Nair 9
Hi Siddharth,

Thanks for the workaround. But for me, my dashboards are getting cut(There are around 9 dashboards in the home page). Is there a way to specify height and width?
My old code was
<apex:page showheader="false" sidebar="false" >
<apex:iframe src="/01Z110000008iUZ?isdtp=nv" scrolling="true" height="1000px" width="100%"/>
</apex:page>
I have changed to :
<apex:page showheader="false" sidebar="false">
        <script>
        location.href="https:cs18.my.salesforce.com/01Z110000008iUZ?isdtp=nv" 
        </script>
</apex:page>

Any help much appreciated.

Thanks,
subbareddysubbareddy
Hi Pramitha,

adjust your dashboard size to "Medium" it will fit in the screen.
to adjust ths dashboard size:
1.click edit on the dashboard.
2.left top corner of the block you can set to medium.
Pramitha Nair 9Pramitha Nair 9
Thanks Venkat. I tried that, but still not resolved my issue completely. Some portion of it is still cut.
subbareddysubbareddy
Hi Pramitha,

try the below code, add "outputPanel"

<apex:page showheader="false" sidebar="false">
<apex:outputPanel id="SalesfunnelDashboard" >
     <script>
      location.href="https://cs13.salesforce.com/01Z50000000xcKR?isdtp=vw";
     </script>
     </apex:outputPanel>
</apex:page>
This was selected as the best answer
Apipoj PiasakApipoj Piasak
Thanks Venkat, Your solution works for me.
Michael StanleyMichael Stanley
Hello Siddharth - I have tried every variation of the coding you have offered to others above and I am not having any luck.  The coding shows up, but not my complete dashboard.  Below is what I have in now.  Any suggestions?

<apex:page showheader="false" sidebar="false">
        <script>
        location.href=https://na10.salesforce.com/01ZF000000114Ha?isdtp=vw 
        </script>
</apex:page>
 
divya divyadivya divya

Hi subbareddy

My scenario is to display the set of dashboard in home page. So i tried code like yours ,but when am clicking the dashboard its not redirecting to particular dashboard. can you please help me out to solve this issue.