Hi All,
I am trying to filter a subgrid based on a lookup field in the entity where the subgrid is located.
I have the following code (below), but consistently keep getting the error "TypeError: Cannot read property 'SetParameter' of undefined"
After going through a lot of forums and blogs I have tried a number of variations such as using "window.parent.document.getElementById(etc..."
However, I have read a lot of suggestions that SetParameter() is no longer supported with newer versions of the CRM - and this is why I am getting the error.
Does anyone know if this true, and if so any alternative I can try?
Thanks!!
function filterSubGrid() { // retrieve the lookup field id var lookup = Xrm.Page.getAttribute("new_discipline").getValue(); var entityid = lookup[0].id.slice(1, -1); var entityname = lookup[0].name; var entitytype = lookup[0].entityType; // testing to console console.log("TESTING!! Entity ID: " + entityid); console.log("TESTING!! Entity Name: " + entityname); // get the subgrid object var subgrid = document.getElementById("supportOffers"); // testing to console console.log("TESTING!! Sub Grid: " + subgrid); if (subgrid == null){ setTimeout(function(){ filterSubGrid();}, 2000); return; } // FetchXML that we want the subgrid to be filtered on including the filter with the entity id of new_discipline var fetchXml = "<fetch version='1.0' output-format='xml-platform' mapping='logical' distinct='false'>" + "<entity name='new_supportoffer'>" + "<attribute name='new_supportoffertitle' />" + "<attribute name='new_discipline' />" + "<attribute name='createdon' />" + "<order attribute='new_supportoffertitle' descending='true' />" + "<filter type='and'>" + "<condition attribute='new_discipline' operator='eq' value='" + entityid + "'" + "/>" + "</filter>" + "</entity>" + "</fetch>"; //set the fetchxml to the subgrid element subgrid.control.SetParameter("fetchXml", fetchXml); // refresh the subgrid implementing the new fetchXml subgrid.control.refresh(); }
*This post is locked for comments