Quantcast
Channel: Sam's Activities
Viewing all articles
Browse latest Browse all 3363

Apply Custom Filter on Lookup Field in Dynamics CRM using Script

$
0
0

Introduction

In this blog we are going to see how to apply custom filter to the lookup field using the JavaScript functions.

In Microsoft Dynamics CRM we can filter a lookup field on form using the Fetch XML condition and “addPreSearch()“ method.

Example

On the Contact Entity there is a lookup field named “Account Name” and a text field “Address1: City” as shown in below screenshot.custom_filter

So, Here If we want to filter Account records in lookup view by city having value equal to field Address1: City. We can do this by writing the below code in Jscript.

Here we have written two functions “filterLookup()” and “addCustomeLookupFilter()”  as shown in the below code snippets.

 custom_filter1

We have created CRM webresource for the javascript and called “filterLookup” function on change event for field “Address1: City” field as below for contact entity form.custom_filter2

Function “filterLookup” will be trigger on change of field “Address1: City”. This binds “addPreSearch” event to lookup control “parentcustomerid”.custom_filter3

Open the contact entity record, Before entering the “Address1:City” field value the lookup field shows all the account records as below screenshot.custom_filter4

Enter the value for “Address1: City” here it is “US” as below.custom_filter5

Then Check for the suggested options for the Account lookup. Only those accounts records will be available to select which having city “US”.

Hope this helps!

There's much more, for more Dynamics CRM Tips and Tricks head on to Inogic Blog. If you have any questions on Dynamics CRM or need any help in implementation, customization, upgradation of Dynamics CRM or are looking to get more out of your CRM, feel free to reach us at crm@inogic.com today!

The post Apply Custom Filter on Lookup Field in Dynamics CRM using Script appeared first on Inogic Blog.


Viewing all articles
Browse latest Browse all 3363

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>