Tuesday, August 13, 2013

Update FetchXML and Refresh sub grid in supported way on rollup 12 and later

Below function can be used to change the fetch XML and refresh the Grid control. This is 100% tested and working without an issue with even latest UR 14 on IE, Chrome and Firefox. I haven't access the DOM directly here since it is not supported.

function PopulateGridFetchXML(sourceFunctionName, subGridName, fetchXML) {
    var subGrid = Xrm.Page.getControl(subGridName);
    if (subGrid._control.get_innerControl() == null) {
            setTimeout(sourceFunctionName, 1000);
            return;
    }
    subGrid._control.get_innerControl().SetParameter("fetchXml", fetchXML);
    // Refresh the grid
    subGrid.refresh();
}

Cheers,

2 comments:

  1. Hi.
    I'm Trying to get this code running in CRM2013 ur1 but cant find the "_control" property. Have you seen this before?
    Thanks!
    / Johan

    ReplyDelete
  2. I cannot get this to work either. The old way in CRM 2011 doesn't seem to be working well either. Confusing...

    ReplyDelete