locked
Java script custom lookup filter code issue RRS feed

  • Question

  • Dear Team,

    I am facing one issue.

    Problem Description: Based on Product category and product Type (combination) i need to filter the product lookup using java script.

    If Product category or product type contains '&' symbol then the product filetering is not working. The following is the code.

    var PCID = Xrm.Page.data.entity.attributes.get("ccs_product_category").getValue()[0].id;
    	
    	var PCName = Xrm.Page.data.entity.attributes.get("ccs_product_category").getValue()[0].name;
            PCName = PCName.replace("&", "&");
    	var PTID = Xrm.Page.data.entity.attributes.get("ccs_product_type").getValue()[0].id;
    	
    	var PTName = Xrm.Page.data.entity.attributes.get("ccs_product_type").getValue()[0].name;
            PTName = PTName.replace("&", "&");
    	var fetchXml = "";
    	fetchXml += "<filter type='and'>";
    	fetchXml += "<condition attribute='ccs_product_category' value='" + PCID + "' uiname='" + PCName + "' uitype11='ccs_product_category' operator='eq'/>";
    	fetchXml += "<condition attribute='ccs_product_type' value='" + PTID + "' uiname='" + PTName + "' uitype='ccs_product_type' operator='eq'/>";     				
    	fetchXml +="</filter>";
    	alert(fetchXml);
    	Xrm.Page.getControl("ccs_product").addCustomFilter(fetchXml);

    Regards,

    Sreenath

    Monday, July 6, 2015 4:45 PM

Answers

  • Hi Sreenath,

    I hope below Url will solve your problem

    http://www.magnetismsolutions.com/blog/nathaneccles/2013/09/30/crm-2013-javascript-lookup-filtering-using-addcustomfilter

    If you find solution, Mark this as answer

    Monday, July 6, 2015 6:46 PM