locked
Urgent help - Lookup Filtering Issue - MS Dynamics CRM Online RRS feed

  • Question

  • Hi Guys,

    I am stucked in one scenario and till now I am not able to find any solution for this. Please help if possible

    Scenario : I have two lookups on Case entity - CaseType and CaseSubType. There is one another lookup on Case form - ProductGroup. I need to filter CaseType field on the basis of ProductGroup selected on case form.

    Data is filtered as per my requirement but i am facing below error on CaseType selection.

    Below is my complete code which is implemented on ProductGroup lookup change.

    There is no syntax error but when i am selecting value in CaseType, i am getting generic error "MS Dynamic CRM encountered an error, for more help contact your administrator"

    Kindly help where I am wrong.

    function setLookupView()
    {

    Xrm.Page.getControl("demo_casetype").addCustomView(viewId,entityName,viewDisplayName,fetchXML,layoutXML,isDefault);
    Xrm.Page.getControl("demo_casetype").addPreSearch(filterCaseType);
    }

    function filterCaseType()
    {

    var productgroup = Xrm.Page.getAttribute("demo_productgroup").getValue();

    if (productgroup != null)
    {
    var _productgroupid = productgroup[0].id;
    var _productgroupname = productgroup[0].name;
    }

    //var viewId = Xrm.Page.getControl("demo_casetype").getDefaultView();
    var viewId = "{C14FE1A3-38AD-E711-8127-C4346BDCDF41}";
    var entityName = "demo_casetype";
    var viewDisplayName = "Filtered Case Type";


    var fetchXML = "<fetch distinct='true' mapping='logical' output-format='xml-platform' version='1.0'>" +
    "<entity name='clix_casetype'>" +
    "<attribute name='clix_casetypeid'/>" +
    "<attribute name='clix_casetype'/>" +
    "<attribute name='createdon'/>" +
    "<order descending='false' attribute='demo_casetype'/>" +
    "<link-entity name='demo_casesubtype' alias='ae' to='demo_casetypeid' from='demo_casetypeid'>" +
    "<filter type='and'>" +
    "<condition attribute='demo_productgroup' value='"+_productgroupid+"' uitype='demo_productgroup' uiname='"+_productgroupname+"' operator='eq'/>" +
    "</filter>" +
    "</link-entity>" +
    "</entity>" +
    "</fetch>";

    var layoutXML ="<grid name='resultset' object='1' jump='demo_casetype' select='1' preview='1' icon='1'>" +
    "<row name='result' id='demo_casetypeid'>" + "<cell name='demo_casetype' width='300'>" + "<cell name='createdon' width='125'>" + "</row>" + "</grid>";

    Xrm.Page.getControl("clix_casetype").addCustomView(viewId,entityName,viewDisplayName,fetchXML,layoutXML,true);
    Xrm.Page.getControl("demo_casetype").addCustomFilter(fetchXML);

    }

    Wednesday, October 11, 2017 8:42 AM