How to add custom filter lookup field based on OptionSet field selection in Dynamics CRM.
In this blog I am going to show how we can filter records based on the selected option set value. For this example I have created an entity and placed 2 fields mainly, One is Option set Field for Region/ Divison and another is Lookup filed of State. So when user will select the region the lookup values will show only filtered records based on the region, copy and paste the code below in your form option set OnChange event which will filter record of lookup. function FilterPackagesLookup() { try { preFilterLookup(); } catch (e) { ShowCatchMessage(e.message); } } function preFilterLookup() { try { if (Xrm.Page.ui.controls.get("new_state") != "undefined" && Xrm.Page.ui.controls.get("new_state") != null) { Xrm.Page.getControl("new_state").addPreSearch(function () { addLookupFilter(); }); } } catch (e) { ShowCatchMess