For some reason, filtering subgrids (Turbo Forms / non-legacy JS engine) in CRM 9.0 is not implemented (yet?!).
A temporary solution for on-premise version would be implementing the addCustomFilter function from the C:\Program Files\Dynamics 365\CRMWeb\_static\form\formcontrols.js library.
Current implementation:
addCustomFilter: function(fetchXmlFilter) { throw Error.notImplemented('The method or operation is not implemented.'); }, |
Fix:
addCustomFilter: function(fetchXmlFilter) { // throw Error.notImplemented('The method or operation is not implemented.'); this.$0_3.get_turboGridControl().addCustomFilter(fetchXmlFilter); }, |
For online version, calling
this.$0_3.get_turboGridControl().addCustomFilter(fetchXmlFilter); |
in your own function should do the magic trick as well.
Note: fetchXmlFilter must be the whole <fetch> node, instead of the <filter> node only. Also, once applying the addCustomFilter on a subgrid, the refresh() function of the grid control must be also called after:
function FilterGrid(gridName, fetchXml) { var grid = Xrm.Page.getControl(gridName); if(grid) { grid.addCustomFilter(fetchXml); grid.refresh(); } } |
what that FetchXML will be?