[SalesForce] Salesforce Dashboard Auto Refresh

I found this javascript code a while ago and was working great until some of the browsers have been updated to newer versions. Now the Home screen "locks up" after some users login. I've seen this issue on Macs, IE9, and sometimes Firefox. Any suggestions on how to keep the script from locking the page? Thanks in advance!!!

I found the code here:

http://teachmesalesforce.wordpress.com/tag/javascript/

<html>
<head>
<script type="text/javascript">
var run;
function refresh()
{
var dashboardButton = document.getElementById('db_ref_btn');
dashboardButton.click()
}
window.onload = setInterval(refresh);
</script>
</head>
</html>

Best Answer

This doesn't require any coding at all. You should be able to schedule a dashboard refresh within Salesforce.


The above is definitely the proper way to do this. I would not really suggest using the script below to do this as the DOM could change and all of this could stop working. Technically it is getting around the need to pay for higher tiered licensing which comes with the scheduled dashboard refresh as well.

With all of that said, the following Javascript should work:

<script type="text/javascript">      
    window.onload = function() { 
        var dashboardButton = document.getElementById('db_ref_btn');
        dashboardButton.click();
    }
</script>

The Javascript you included doesn't really make much sense. You have a run var you never use, and then you use setInterval() without specifying an interval to refresh on. This code will basically just click the Refresh button once the page loads.

Related Topic