Posted on 2. February 2013

Adding Auto Refresh to Dashboards

This post shows you how to set up a CRM2011 Dashboard 'auto-refresh' feature using the Ribbon Workbench in 10 easy steps (well…11 if you count clicking publish at the end!).

We will add an auto refresh function to the 'EnableRule' of the Dashboard refresh button that schedules a refresh using the 'setTimeout' function. The EnableRule is called when the dashboard page is first displayed to check if the Refresh Button should be enabled. We schedule the refresh, and then return true to ensure the button is still enabled. This technique can also be used to add JavaScript to areas of CRM 2011 that are not form based.

Let's get started:

1) Create a new solution and add the Application Ribbon to it (Client Extensions->Add Existing->Application Ribbon).

2) Create a new web-resource named 'RefreshRibbon.js' (or something similar)

Add the following JavaScript to it:

var AUTO_REFRESH_INTERVAL=30000;
/// Schedule the first refresh if we havn't already
function autoRefreshDashboards() {
    var topWindow = window.top;
    if (typeof (topWindow['refreshRegistered']) === 'undefined') {
        window.setTimeout(autoRefreshTimeoutCallback, AUTO_REFRESH_INTERVAL);
        topWindow['refreshRegistered'] = true;
    }
    return true;
}
// Refresh the dashboards and schedule the next refresh
function autoRefreshTimeoutCallback() {
    try {
        Mscrm.DashboardRibbonActions.refreshDashboardPage();
        window.setTimeout(autoRefreshTimeoutCallback, 30000);
    }
    catch ($e1) {
        // Perhaps the dashboards are no longer loaded. and we are on a different page
    }
}

Note: You can change the refresh interval using the 'AUTO_REFRESH_INTERVAL' value which is in milliseconds (30000=30 seconds)

Your solutions should now look something like:

  • 3) Open the Ribbon workbench, and load up your new solution.

    4) Select the 'Application Ribbon' in the 'Entities' panel if not already, then select the 'Dashboards' tab in the Design surface (be sure to select 'Dashboards' and not 'Dashboard')

    5) Right click on the 'Refresh All' button and click 'Customise Command' (Not Customise Button)

  • 6) Locate the 'Mscrm.DashboardTools.RefreshCommand' command in the 'Commands' section of the 'Solution Elements' panel. Right click, and select 'Edit Enable Rules'

    7) In the Enable Rules dialog click '+Add New' and then select 'Add Step', before selecting 'Custom JavaScript Rule'

    8) In the Enable Rule properties, set:

    FunctionName: 'autoRefreshDashboards'

    Library : Click the lookup button and select the 'RefreshRibbon.js' (If you don't see it, then you forgot to add the javascript webresource you created above to the solution you loaded into the Ribbon Workbench)

    9) Click OK, and OK again.

    10) In the 'Solution Elements' panel, expand the 'Enable Rules' and select 'Mscrm.IsDashboardSelected'. In the properties panel, set 'IsCore' = True.

    This ensures that this rule is not customised in our solution since we only need to customise the Command to add the new enable rule.

    11) Click Publish Solution

    And you're done! This will work both in the Web Browser and the Outlook client. It is important that you remember that auto-refreshing dashboards could place more load on your server if lots of users leave the dashboards open all day!

    Until next time…

    @ScottDurow

    Comments

    pingback dexpage.com
    10:48 AM on Friday, June 26, 2015

    Pingback from dexpage.com

    Add button to Default Dashboard Command Bar - CRM online - DexPage

    pingback cssphp.space
    7:03 AM on Thursday, January 14, 2016

    Pingback from cssphp.space

    Add button to Default Dashboard Command Bar - CRM online - CSS PHP

    pingback kara48.informationzone9.info
    3:30 AM on Saturday, January 28, 2017

    Pingback from kara48.informationzone9.info

    How To Auto Refresh A Php Page | Information

    Comments are closed