Wednesday 15 July 2015

CRM 2015: JavaScript – Lookup Filtering using addCustomFilter


Here is my new post with the new java scripts in CRM for filtering lookup. In this post I am going to describe how to use addCustomView function to filter the lookup value.


Below I will show you how to filter a lookup based on the value of another field on the form. In this scenario we will be using the LookupField1 to filter the Parent Account lookup to only display Accounts with a matching LookupField1 value, and to display all Accounts when no LookupField1 value is specified.

To filter this we use the following code, and call the “getFilteredLookup” function on load and onChange of "LookupField1" of the form.

Click on the Image to Enlarge....



To create a fetchXml best way is to go and create an Advanced Find in CRM according to your condition and download the fetchXml.

After that you need to write an layoutXml for new lookup .For this i suggest copy the above code which i have written and change the row "id" and cell "name".

For viewId just provide any "id"({00000000-0000-0000-0000-000000000001}) as u like in above format and make sure it doesn't match with your default viewId.

Hope this would be helpfull to you.
Enjoy the great technology CRM.  Good Luck




1 comment:

  1. Thanks for writing such a good article, I stumbled onto your blog and read a few post. I like your style of writing... nonprofit consultants

    ReplyDelete