DESCRIPTION
In this blog, we will learn how we can dynamically filter lookup columns in Dynamics 365 Customer-Engagement based on a selected choice (option) in an option-set field. Consider an option-set called Contact Type having the following options (choices). The Parent Contact and Account Name (Parent Company) lookup fields must be filtered as per the following table.
S.No. | Contact Type Option | Account Type Option | Integer Value |
---|---|---|---|
1 | Family Member | Support Staff | 100000000 |
2 | Franchise Contact | Franchise Unit | 100000001 |
3 | Vendor Contact | Vendor | 100000002 |
We’ll make use of the addPreSearch and addCustomFilter JS functions to achieve the above programmatically.
STEPS
1. We create a new JavaScript Web-Resource with the following code.
2. Add this library function On-Load of Contact main form and On-Change of Contact Type Field.
UNIT-TESTING
1. When Contact Type is Family Member:
Parent Contact Lookup
Account Name Lookup
2. When Contact Type is Franchise Contact:
Parent Contact Lookup
Account Name Lookup
3. When Contact Type is Vendor Contact:
Parent Contact Lookup
Account Name Lookup
Conclusion
Thus, by Microsoft dynamics CRM development making use of the addPreSearch and addCustomFilter JS functions, we succeeded in developing a mechanism to dynamically filter the Parent Contact and Parent Company lookups based on the selected Contact Type option.