Salesforce Dashboard Rotation and Refresh with Tampermonkey

13 Jan

Have you ever wanted to rotate through a series of Salesforce dashboards and have them auto refresh? There are multiple questions on the success community and other forums requesting exactly this. The easiest way to rotate through dashboards is to use a browser plugin that switches between pages. However, data in the dashboards can only be scheduled to refresh once per day. A more frequent refresh requires a user to click the refresh button on the dashboard page.

Enter the Tampermonkey browser plugin and a little Javascript. Tampermonkey is a plugin that allows you to execute Javascript code when a page loads in the browser. To solve the problem of getting a refreshed rotation of dashboards, I wrote a little Javascript code that will redirect to a series of dashboard URLs and automatically click the refresh button without user interaction.

  1. Install the Tampermonkey plugin to Chrome or Firefox.
  2. Create a new Tampermonkey script and paste in the code below.
  3. Update the URLs from “” to reflect your instance’s URL.
  4. Update the list of dashboard record ids in the code. Navigate to the dashboard page, and you will find the record id in the location bar of the browser.
  5. Navigate to a dashboard page, add the URL parameter “&rotate=true” to the end, and press enter.
// ==UserScript==
// @name         Salesforce Dashboard Rotator
// @namespace
// @version      0.1
// @description  Rotate through  series of Salesforce dashboards. Refresh them after they have loaded.
// @author       David Helgerson
// @match*?rotate=true
// @grant        none
// @require
// ==/UserScript==

(function() {
    'use strict';

    * rotate through an array of dashboard page IDs
    function changeDashboard() {
        var baseURL = '';
        var dashboardIdList = [
        var arrayLength = dashboardIdList.length;
        var nextPage = '';
        var saveNext = false;
        for (var i = 0; i < arrayLength; i++) {
            if ('' === nextPage) nextPage = dashboardIdList[i];  // save first
            if (true === saveNext) {
                nextPage = dashboardIdList[i];
            if (baseURL+dashboardIdList[i]+'?rotate=true' == window.location.href) {
                saveNext = true;
        if ('' !== nextPage) {
            window.location.href = baseURL+nextPage+'?rotate=true';
    * click the dashboard's refresh button
    function autorefresh() {

    * remove elements at the top of the page, so dashboards have more screen real estate 
    function removeHead() {
        $( "#AppBodyHeader" ).remove();
        $( ".ptBreadcrumb" ).remove();

    // run after page loads
    window.addEventListener('load', function() {
    }, false);

    // run delayed
    setTimeout(autorefresh, 27000);  // click the refresh after 27 seconds, so the dashboard will be refreshed when it appears on the next rotation.
    setTimeout(changeDashboard, 30000);  // rotate to the next dashboard after 30 seconds.