Customize Customer Lookup to show only Accounts or Contacts

In some projects we may need customize the Customer look up on Case, Opportunity etc.. for showing only Accounts or Contacts based on some conditions.
We can achieve this using addPreSearch and addCustomFilter in JavaScript. Let us see this now.

I have taken Case entity here.

By default, Customer Look up shows Accounts and Contacts.



Let us customize it by writing some JavaScript code. The method is called on the load event, you can use it based on your requirement.

Here is the JavaScript code

function OnLoad() {
function addEventHandler() {
// For showing only Contacts.
function addFilterToShowContacts() {
    var account_filter = “” +
     “” +
    Xrm.Page.getControl(“customerid”).addCustomFilter(account_filter, “account”);
// For showing only accounts.
function addFilterToShowAccounts() {
    var account_filter = “” +
    “” +
    Xrm.Page.getControl(“customerid”).addCustomFilter(account_filter, “contact”);
Showing Only Contacts

Showing Only Accounts

The only problem I see in this approach is User has select the dropdown(Account/Contact) but this is only supported way we have. Let’s hope next versions of CRM will give some other technique to solve it for us.

Hope this helps.

Happy CRM’ing

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s