Take the 2-minute tour ×
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It's 100% free, no registration required.

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>
share|improve this question
add comment

2 Answers 2

up vote 4 down vote accepted

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.

share|improve this answer
    
Agreed, but there is a limit to how many dashboards I can auto refresh which is why I resorted to the script. –  JustAGirlyGeek Feb 15 '13 at 18:10
1  
I believe I also added the script because the users were getting confused as to why the dashboards weren't automatically refreshing. –  JustAGirlyGeek Feb 15 '13 at 18:17
    
Just curious...is there some reason that Salesforce doesn't let you refresh this often...is this potentially somehow not allowed... –  Peter Knolle Feb 15 '13 at 18:34
    
@PeterKnolle - Normally you have to use one of your scheduled job slots for dashboard refreshes, same as running a report. And you don't get many slots. –  Mike Chale Feb 15 '13 at 18:35
    
Salesforce does limit this type of thing for performance issues as well as charging more for the ability to even do this. I don't really know if this type of thing is a violation, as mentioned in my post. –  Jesse Altman Feb 15 '13 at 18:40
show 1 more comment

If you're on or Enterprise and Ultimate editions the schedule auto-refresh feature will works.

For other editions, you'll need the javascript to make it work. They limit this to keep you from doing something crazy like "run a report of all activity history for the past X months... auto-refresh every 5 minutes"

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.