Question

Our setup is Outlook 2010 + CRM addin connected to a 2013 online instance.

I have some custom ribbon buttons on the lead grid ribbon that manipulate selected leads. After certain operations, I would like to tell Outlook to refresh the current view as the operation has updated selected leads so they should no longer show in the current view.

Currently, I have to explain to users that the view updates on its own schedule and they must manually refresh the view (View tab/Refresh button) if they want it to happen immediately. Not surprisingly I am getting a lot of complaints about this!

This seems to suggest that there is a way to programmatically refresh the view but I don't understand the details of how to get it working.

Here is some info with pics on the manual refresh.

Here's a pic of the Outlook view I need to refresh with custom button JS: enter image description here

Was it helpful?

Solution

The view can be refreshed in 2011 in an unsupported manner, so this code may not work in 2013 and may break with some update rollups.
The anonymous function must be in an library that is referenced by a ribbon button; there are no events or Xrm object on views.
I created a new hidden ribbon button (Ribbon Workbench works well) that had an action that referenced the JavaScript library that contained this function; the function does not need to be called - it runs when the library is loaded.

var seconds = 30;
/*  
 * @param {int} inSeconds: how often the view should refresh in seconds  
 * */ 
(function (inSeconds) {     
    var interval = setInterval(function () {         
        document.getElementById("crmGrid").control.refresh();     
    }, inSeconds * 1000); 
}(seconds));
// The line to refresh the grid is not supported

What can be done in a supported manner is to refresh a sub-grid on a form; if you could get users to work from a form instead of a view you can use this supported code and call it in a manner like above or rather on the onload event:

Xrm.Page.ui.controls.get("sub_grid_name").refresh();
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top