
We have setup CRM 2016 with Turbo form rendering enabled.
I am getting an issue with regard to existing code of Binding a subgrid with custom fetch xml .
The code snippet looks like the following
var gridOpenActivity = document.getElementById("grid_openActivity");
gridOpenActivity.control.SetParameter("fetchXml", fetchXml); //set the fetch xml to the sub grid
gridOpenActivity.control.refresh(); //refresh the sub grid using the new fetch xml
But the code is firing an error at SetParameter
I tried updating the code to remove the unsupported js as shown below
var gridOpenActivity = Xrm.Page.getControl("grid_openActivity").getGrid().$3_1;
var gridOpenActivity = document.getElementById("grid_openActivity") || window.parent.document.getElementById("grid_openActivity");
if (gridOpenActivity) {
grid = gridOpenActivity.control;
}
grid.SetParameter("fetchXml", fetchXml);
But now I am not getting the error at SetParameter but the Result from fetch xml is not getting binded and not display the expected result.
*This post is locked for comments
I have the same question (0)Hi,
Use this.
//bind custom fetch to subgrid
function bindCustomFetchToGrid(){
var yourGrid = Xrm.Page.getControl("grid_openActivity"); //get subgrid control
if(yourGrid == null){
//re-runs the function call if the subgrid control hasn't been fully loaded
setTimeout(function () {
bindCustomFetchToGrid();
}, 2000);
return;
}
var customFetchXML = "<your fetchXml query here>";
//Set the fetchxml directly to subgrid
yourGrid.control.SetParameter("fetchXml", customFetchXML); //pass your fetchxml
yourGrid.control.Refresh(); //refresh subgrid to show the fetched results
}