+ Start a Discussion

How to Auto-Refresh a Dashboard?


I'd like to put up a big screen in our sales department showing a dashboard. But in order for that to be of any interest, data has to be somewhat up-to-date.

My idea was to create a simple VisualForce Page which shows the dashboard and a small piece of JavaScript which clicks the Refresh button every hour.

However, I'm having problems getting the script to actually click the Refresh button. I could get it to work in a Home Page Component but showing the dashboard there isn't really an option.

Does anyone have anything similar running who would be interested in sharing their code?


Søren Nødskov Hansen


r u able to put the dashboard in to a vfpage?




Yes, sorry for not including my code the first time around. My VisualForce Page is as follows:



<apex:page standardController="Dashboard" cache="false" showHeader="false" sidebar="false" title="Auto-Refresh Dashboard">
  <apex:iframe src="{!URLFOR('/my_dashboard_id')}" scrolling="true" />
  <script type="text/javascript">
    function refreshDashboard() {
      var dashboardButton = document.getElementById("refreshButton");
    window.setTimeout("refreshDashboard();", 60*60*1000); // refresh every 60 minutes

 The script is being executed correctly but the refresh button is never cliced. When I try to output the dashboard button, I get null which is strange as I've found the id using FireBug.




Søren Nødskov Hansen



Your dashboard is coming from salesforce.com and your VF page is coming from force.com so there is some cross site scripting blocking in the browser.

(search: cross site scripting)

You would only be able to auto-refresh a dashboard in a standard page.


There was aome posts about a self-refreshing dashboard





If there was a web-API to refresh dashboards then perhaps your VF page could do that, and then refresh itself to pick up the updated dashboard.


You can use Custom HTML components on any page by using Setup > Customize > User Interface. Check the option for "custom sidebar components on all pages." Then, modify your code to check to see if it is on a dashboard page, and read the "last refresh" time stamp, and if older than one hour, click the Refresh button.


Hi sfdcfox,


I see where you're going with this and I can see how it would solve my problem.


I've modified the code according to your comments and enabled custom sidebar components on all pages as you mentioned.


Now, my only problem is that the sidebar doesn't show when I view the dashboard. Actually, the sidebar doesn't show on any of the dashboard pages.


I've checked that the sidebar shows (and the code is being executed correctly) on other pages. However, that is not the case for any of the dashboards.


Any suggestions?




Søren Nødskov Hansen


Ok, so it doesn't seem to be possible to display the sidebar on a dashboard page...


However, a friend of mine with little technical knowledge of SF came up with the idea to use FireFox together with Greasemonkey. He's actually put something together which works perfectly.


Not the most smooth approach, I know, but it gets the job done. At least until a proper solution can be put together.


/Søren Nødskov Hansen


This is something that has been vexing me for a while, and I think I've cracked it using standard Salesforce.


I've posted the details on my blog at:




(I've also posted this on the LinkedIn thread).

Delinda TinkeyDelinda Tinkey
This is simple and works great for me: http://www.chiragmehta.info/chirag/2012/12/19/auto-refresh-salesforce-dashboard-every-5-10-or-15-seconds-minutes-or-hours/
Alexander Pinate 9Alexander Pinate 9
Do I have to literally copu and paste this in the URL bar in the browser with no changes?:
javascript:function autorefresh() {document.getElementById('refreshButton').click();setTimeout(autorefresh, 5000);}autorefresh();