Hello guys,
Today I faced some weird behavior of a javascript function provided by Microsoft maybe I am making it wrong. I am using addPreSearch for a lookup on my custom entity to add a custom view using addCustomView function and that's working fine for filtering of records but when I select the record and save that The lookup resets its selected value and gets empty. I don't why this happening. The code for this is below:
function preFilterLookup(econtext) { debugger; // add the event handler for PreSearch Event Xrm.Page.getControl("nfs_product").addPreSearch(addFilter); } function addFilter() { //check if the city is not empty debugger; var functionName = "setCustomView"; var viewId = "{00000000-0000-0000-0000-000000000001}"; var entityName = "product"; var viewDisplayName = "Products from Price list"; var fetchXml = "<fetch mapping='logical' version='1.0' distinct='true' output-format='xml-platform'> " + "<entity name='product'>" + "<attribute name='name' />" + "<attribute name='productid' />" + "<attribute name='productnumber' />" + "<attribute name='description' />" + "<attribute name='statecode' />" + "<attribute name='productstructure' />" + "<order descending='false' attribute='productnumber' />" + "<link-entity name='productpricelevel' to='productid' from='productid' alias='ae' link-type='inner'>" + "<filter type='and'>" + "<condition attribute='pricelevelid' operator='eq' uitype='pricelevel' value='" + Xrm.Page.data.entity.attributes.get("nfs_pricelist").getValue()[0].id + "' />" + "</filter>" + "</link-entity>" + "</entity >" + "</fetch >"; var layoutXml = "<grid name=' resultset' object='1' jump ='productnumber' select ='1' icon ='1' preview ='1'>" + "<row name='result' id=' productid'>" + "<cell name='name' width='150' />" + "<cell name='description' width='150' />" + "<cell name='statecode' width='150' />" + "</row>" + "</grid >"; Xrm.Page.getControl("nfs_product").addCustomView(viewId, entityName, viewDisplayName, fetchXml, layoutXml, true); }
*This post is locked for comments