HI Experts,
We upgraded our CRM onpremises 2015 to D365 onpremise and stuck with subgrid issue. Subgrids are not loading as before in 2015.
Our requirement is to filter the records from system users entity depending on site executive roles and display them in subgrid on another custom entity form. We are maintaining N:N relation ship between both.
We took the code from
https://paulnieuwelaar.wordpress.com/category/dynamics-crm-2016/
and customized it as per our requirement. When we debugged the code we are getting error gridControl.GetParameter is not a function
Also when we used var crmWindow = Xrm.Internal.isTurboForm() ? parent.window : window; It said Xrm.Internal.isTurboForm() is not a function
//filters an add existing lookup view (N:N) function addExistingFromSubGridCustom(gridTypeCode, gridControl, crmWindow, fetch, layout, viewName) { var viewId = "{1DFB2B35-B07C-44D1-868D-258DEEAB88E2}"; // a dummy view ID var relName = gridControl.GetParameter("relName"); var roleOrd = gridControl.GetParameter("roleOrd"); //creates the custom view object var customView = { fetchXml: fetch, id: viewId, layoutXml: layout, name: viewName, recordType: gridTypeCode, Type: 0 }; var parentObj = crmWindow.GetParentObject(null, 0); var parameters = [gridTypeCode, "", relName, roleOrd, parentObj]; var callbackRef = crmWindow.Mscrm.Utilities.createCallbackFunctionObject("locAssocObjAction", crmWindow, parameters, false); //pops the lookup window with our view injected crmWindow.LookupObjectsWithCallback(callbackRef, null, "multi", gridTypeCode, 0, null, "", null, null, null, null, null, null, viewId, [customView]); } //filters the Contact N:N lookup view from Account to show only Pauls!! function filterAddExistingContact(gridTypeCode, gridControl, primaryEntity) { var crmWindow = Xrm.Internal.isTurboForm() ? parent.window : window; if (primaryEntity != "account") { crmWindow.Mscrm.GridRibbonActions.addExistingFromSubGridAssociated(gridTypeCode, gridControl); //default button click function return; } //fetch to retrieve filtered data var fetch = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" + " <entity name='contact'>" + " <attribute name='fullname' />" + " <order attribute='fullname' descending='false' />" + " <filter type='and'>" + " <condition attribute='statecode' operator='eq' value='0' />" + " <condition attribute='firstname' operator='eq' value='Paul' />" + " </filter>" + " </entity>" + "</fetch>"; //columns to display in the custom view (make sure to include these in the fetch query) var layout = "<grid name='resultset' object='1' jump='contactid' select='1' icon='1' preview='1'>" + " <row name='result' id='contactid'>" + " <cell name='fullname' width='300' />" + " </row>" + "</grid>"; addExistingFromSubGridCustom(gridTypeCode, gridControl, crmWindow, fetch, layout, "Filtered Contacts"); }
It worked fine in 2015 version but once we upgraded CRM to D365
Please review and let us know where we are doing wrong, or is there any other way to handle it in D365.
Regards,
Nazar