April 3, 2006

Homepage and Dashboard Auto-Refresh

Filed under: Howto, Code, Salesforce.com — heretic @ 11:56 pm

The Salesforce.com customer forums has some interesting discussions from time to time. Back in December Salesforce.com user jay07 posted a thread entitled “Favorite Home Page Elements.” In it some nice home page components were disccused. I offered my personal favorite - the homepage auto-refresh.

My placing an HTML META refresh tag inside the “Messages and Alerts” homepage component you can cause the home page to reload at certain intervals. The upside to this change is that users who leave their homepage acive in the background of their PC will never be logged out of the system. It’s also a significant drawback too.

A user replied asking if there was a way to have the dashboard automatically refresh too. Unfortunately at the time while there was a way to do it, it wasn’t very pretty. With the new UI in the Winter ‘06 release this became alot simpler.

First, both of these tricks should work in just about all browsers. Firefox and IE for sure.

Second, use these at your own risk, and understand the repercussions of their use. If you have alot of users the dashboard auto-refresh will likely cause far more harm then good, especially if your users like to watch the app’s homepage.

Lets take a look at a typical meta refresh tag. Implementing this will cause your SFDC homepage to refresh every 10 minutes (600 seconds). You can copy and paste this right inot the Messages and Alerts box in setup.

<meta http-equiv=“refresh” content=“600″ />

This is a bit different then a regular refresh tag in that it doesn’t specify a URL to refresh to. Your browser will refresh to the same page being viewed, so this code will work on all SFDC instances. Remember that doing this means that any user who leaves their PC logged into the home page will never be logged out by timeout. One user who locked their office workstation and left SFDC logged in still had a valid session when they returned from their two week vaction. Use with caution.

The next one is a piece of Javascript that will simulate a click on the “Refresh” button for your dashboard component. First, using this with the meta refresh tag above will likely not have the result you want. If the meta refresh tag triggers a refresh before the button is due to be clicked, the dashboard will never update using this method. Also, remember that this auto-clicking will be enabled for every user in the system what has this shown on their home page. If you’ve got 5-15 users it’s probibly not a problem if the interval is high enough. But if this is enabled for a 500+ seat org your dashboard may be constantly updating, whish will likely cause your administrator to catch hell from Salesforce.com.

This example has the dashboard refreshing every 60 minutes.

<script type=“text/javascript”>
function refreshDashboardTimeout() {
var dashboardButton = document.getElementById("db_ref_btn");
dashboardButton.click()
}
// 60m * 60s * 1000ms
window.setTimeout("refreshDashboardTimeout();", 60*60*1000);

Enjoy!

License

This work is published under a Creative Commons Attribution-ShareAlike 2.5 License.

7 Comments

  1. Another SF blog - Awesome!

    The message board link will lead to a infinite sign-in loop for some users. Try this link instead: http://forums.sforce.com/sforce/board/message?board.id=practices&message.id=1469

    PS: your comments form uses white text on a light gray background.

    Comment by Kingsley — April 4, 2006 @ 11:47 am

  2. Thanks Kingsley — Haven’t had to use the comment form so I didn’t catch the color issue. Should be fixed now.

    And as for the URL used… It’s a Lithium forum, so use whatever one seems to be working for you. ;)

    Comment by heretic — April 4, 2006 @ 12:38 pm

  3. […] But they took a different tack here, and exploited a hack that has been available for awhile, but became more useful in Winter ‘07. One the home page of your Salesforce.com instance, you can put arbitrary text, and the Salesforce Heretic showed how you could put code blocks in here and make things happen in Salesforce.com. […]

    Pingback by gokubi.com » Blog Archive » Salesforce.com Autocomplete may hint at future customization angle — February 1, 2007 @ 1:47 pm

  4. I’m not a programming type but can you explain step by step how I would implement this code?

    Comment by Mark — February 14, 2007 @ 5:58 pm

  5. Hello,
    I’d like to know how to use that code snippet with refreshDashboardTimeout() function as well. Do we have to copy it into the Messages and Alerts box? I tried it and didn’t seem to work.
    We are trying to get the dashboard to auto-refresh and maintain page session timeout property as well. Do you have a solution to this?
    Thanks.

    Comment by Supriya — March 8, 2007 @ 5:47 am

  6. Does anyone know how to implement this as Im just getting an empty home page when I try to do this?

    thanks

    Comment by Dearnr — April 13, 2007 @ 4:40 am

  7. Hi,

    Has anyone successfully implemented this change and is it still possible?

    thanks

    Comment by Dunc — May 14, 2007 @ 8:27 am

RSS feed for comments on this post.

Sorry, the comment form is closed at this time.