locked
CRM 2015 Refresh assosiated view grid on button click RRS feed

  • Question

  • Hi,

    I have a custom button which create a record and after click the button i need to refresh the assosiated view so that the newly created record is visible on the assosiated grid

    I have tried the below code in 2011 and it was working fine but in 2015 its not working

    function refreshSubgrid(subgridName) {
        var gridControl = document.getElementById(subgridName);
        if (gridControl != null) {
            Xrm.Page.ui.controls.get(subgridName).refresh();
        }
        else {
            setTimeout(function () {
                refreshSubgrid(subgridName);
            }, 500);
        }
    }

    Please advise

    Thanks

    Varun

    http://mscrmbi.blogspot.com/


    Monday, September 21, 2015 9:20 AM

All replies

  • Hi Varun,

       Use below JS to refresh Subgrid in CRM 2015, You can call this js from ribbon button. 

        Xrm.Page.ui.controls.get("yoursubgridname").refresh();


    Monday, September 21, 2015 10:47 AM
  • I have already tired this but its not working. This was working in 2011. 

    Please see the code i have originally posted

    Monday, September 21, 2015 11:17 AM
  • document.getElementById(subgridName); DOM is not supported in CRM 2015

    so try to get grid control as

    var gridControl= Xrm.Page.getControl(subgridName);

    function refreshSubgrid(subgridName) {
        var gridControl =Xrm.Page.getControl(subgridName);
        if (gridControl != null) {
            Xrm.Page.getControl(subgridName).refresh();
        }
        else {
            setTimeout(function () {
                refreshSubgrid(subgridName);
            }, 500);
        }
    }


    Muhammad Sohail

    Monday, September 21, 2015 1:03 PM
  • Hi,

    The script above would be unsupported as it manipulkates the dom object.

    to refresh a sub grid in 205 use..

    Xrm.Page.ui.getControl('subgridName').refresh();

    or

    Xrm.Page.getControl('subgridName').refresh();

    
    
    
    Monday, September 21, 2015 2:51 PM