Dear Dynamics People,
As many time we receive requirement that shows only some specifics data in the lookup field. In sub gird, we can create a view with specifics condition and shown in it. But for lookup view is always fix we cannot apply another view.
To achieve this requirement need to apply JavaScript to two function addPreSearch and addCustomFilter
function FilteraccountList() { var account = Xrm.Page.getAttribute("accountcustomer").getValue(); if (account != null) { var accountTextValue = account[0].name; var accountID = account[0].id; Xrm.Page.getControl("accountcustomer").addPreSearch(function () { var account_filter = "<filter type='and'>" + "<condition attribute= 'number' operator='not-null' />" + "<condition attribute='code' operator='eq' value='287850000' />" +"<condition attribute='account' operator='eq' name='" + accountTextValue + "' value='" + accountID + "' />"+ "</filter>"; Xrm.Page.getControl("accountcustomer").addCustomFilter(account_filter, "account"); }) } }
Apply this function to form onload and lookup filed onchange.
Thanks
*This post is locked for comments