Since there is no supported way to filter a grid over MS CRM till now. An unsupported way expire from version to version.
For CRM 2016 and above, use below code to filter a sub grid if parent entity and child entity doesn’t have any relationship and you wish to filter a grid base on lookup value.
function FilterSubgrid()
{
var filterId = Xrm.Page.data.entity.getId();
var yoursubgridnameObject = window.parent.document.getElementById(“<GridName>”);
if (yoursubgridnameObject == null || yoursubgridnameObject.control == null) {
setTimeout(‘FilterSubgrid()’, 1000);
return;
}
if (filterId == null) return;
var fetchXml = “<fetch version=’1.0′ output-format=’xml-platform’ mapping=’logical’ distinct=’true’>”;
…
fetchXml =fetchXml+ “</fetch>”;
yoursubgridnameObject.control.SetParameter(“fetchXml”, fetchXml);
yoursubgridnameObject.control.refresh();
}
Thanks.