Hi,
I am trying to setup a custom filter for one of my subgrids. It basically needs to show all the emails associated to a person(custom entity) sent from an entity(Activity enabled). Here is my script.. it does bring the filtered records as I checked while debugging, it just does not set the filter for some reason. Not sure how else to troubleshoot and so I need some help. Thanks for any help!
function SubGridFilterExecution(executionContext) { //Create a Form Context. var formContext = executionContext.getFormContext(); //Step 1 - Get the subgrid control. var gridContext = formContext.getControl("Subgrid_new_EventsMailMerge"); //Step 2 - Retrieving Form Attribute Value. var fullName = formContext.getAttribute("new_personname").getValue(); //Step 3 - Recall the execution method if the subgrid context is null or empty. if (gridContext == null) { setTimeout(SubGridFilterExecution, 3000); return; } else { //Set grid with query A based fetch XML. if (fullName != null) { //Step 4 - Build a fetch XML in a variable. var FetchXmlA = "" "" "" "" "" "" "" "" "" "" "" "" "" "" ""; //Query the records Xrm.WebApi.retrieveMultipleRecords("email", "?fetchXml=" encodeURIComponent(FetchXmlA)).then( function(results) { var functionalLocationsFilter = results.entities.map( function(r) { debugger; return ("" r._regardingobjectid_value ""); }).join(""); //Composing the resulting filter for the grid var filter = [ "", "", functionalLocationsFilter, "", "" ].join(""); gridContext.setFilterXml(filter);//debug stops here and exits. subgrid shows no data gridContext.refresh(); }, Xrm.Navigation.openErrorDialog); } } }