Hello,
I am filtering subgrid on load of form from javascript function with the following code.
But for first time its loading all records of entity as its default view is All Active records instead of loading filtered records. But it is loading if i change view of grid from Active to inactive and back to Active after loading form.
Is this issue is getting due to filter is applying first and loading All records of entity ? Please provide for this issue.
I am passing contact id and case id to fetch xml and passing it to grid.
setFetchXmlToGrid: function (fetchXmlString, gridName) {
debugger;
var subGrid = Xrm.Page.getControl(gridName);
var grid = subGrid.getGrid();
if (grid != null) {
var contactLookup = Xrm.Page.getAttribute(Contact).getValue();
if (contactLookup != null) {
var contactId = contactLookup[0].id.replace("{", "").replace("}", "");
var caseId = Xrm.Page.data.entity.getId().replace("{", "").replace("}", "");
var fetchXml = fetchXmlString.replace("[contactId]", contactId).replace("[caseId]", caseId);
grid.setParameter("fetchXml", fetchXml);
}
}
else {
setTimeout(function () { setFetchXmlToGrid(fetchXmlString, gridName); }, 2000);
return;
}
},
Thanks,
Krishna Prasad.