Thursday, March 29, 2012

Refresh Selected View on Button Click in CRM Ribbon

You may have implemented many buttons in CRM Ribbon area to perform your business transactions. And you may create new records, update or delete the records in the grid once the user clicks the Ribbon button. Then you may need to refresh the Grid.

There are many ways to refresh the page or grid, but the issue is once the page reload you will loose the selected view and CRM will load the Default View, instead of the user selected view. And if you want to keep the user selected view even after the Grid is refreshed, You can call the below java script inside your 'ribbon button click' after doing your actions, and before function ends.

grid = window.parent.frames('contentIFrame').document.getElementById('crmGrid');
grid.Refresh();

2 comments:

  1. Hi this did not work for me. It says "Unable to get value of the property 'Refresh': object is null or undefined"
    I am trying to close an opportunity with a dialog process on click of a button and then refrech the list view.
    Any suggestions!

    ReplyDelete
    Replies
    1. Did you implement your coding in inside the button click in Process Dialog? If so, since you are window is displayed as a modal window, there is no parent exists for the window. Hence the window.parent will be always null.
      This code works, if you put this code on Ribbon or if you paste this in your custom web page, which runs not as a modal dialog.

      Delete