Customer type Lookups in Dynamics CRM have always been an interesting and powerful feature that allows you to associate records of multiple entities with entities like Cases, Orders, etc. PartyList Lookups are similar to Customer type lookups, except for the fact that it allows you to have access to a vast array of entities. They are generally available in Activities like Appointments, Phone Calls, etc.
Sometime or the other, you might have had the requirement to modify customer type lookup in CRM to restrict records to a particular entity. For example, you might want to restrict the end user from selecting Accounts while placing an Order from the “Customer” Lookup. Well, there’s a way to achieve that in CRM using JavaScript. It isn’t exactly a supported one. But chances of Rollups breaking it is very less.

What to change and where
Things are a bit different in CRM 2013. In CRM 2011 and even CRM 4.o, the DOM was a litte bit different. But CRM 2013 has its own brand new DOM structure. So, the code differs from that of CRM 2011. If you simply want to get to the code to implement, you can move directly to the next section. If you want to know why that code is required, read on. 🙂
Let us consider the Phone Call form as an example. So, we open up a new Phone Call form.

Consider we want to restrict the Regarding lookup to a specific entity, Account. If you’re using Internet Explorer, press F12 to open up the Developer Tools. Search for “regardingobjectid_i” and you’ll find something as follows.

Now, this “regardingobjectid_i” is basically the magnifying glass image in the “Regarding” lookup button. It consists some interesting properties that determine what entities will be displayed in the lookup form. However, we are interested in only a handful of them in order to get our job done. They are “lookuptypes”, “lookuptypeIcons”, “lookuptypenames” and “defaulttype”. Having a closer look at them pretty much explains what each property signifies.
So, now that we have identified what needs to be changed where, let’s get to the coding part of it. Basically, the idea here is to append “_i” after the Customer type lookup field name. Once you get that element, change its properties to get the desired result.
JavaScript to modify Customer type Lookup in CRM
If you have followed the earlier section, you’d know why the following code snippet is required and what exactly it does. Just to be on the same page, the following code will allow only “Account” records to be displayed in the “Regarding” lookup field (in the Phone Call entity).
1 2 3 4 |
document.getElementById("regardingobjectid_i").setAttribute("lookuptypes", "1"); document.getElementById("regardingobjectid_i").setAttribute("lookuptypeIcons", "/_imgs/ico_16_1.gif"); document.getElementById("regardingobjectid_i").setAttribute("lookuptypenames", "account:1:Account"); document.getElementById("regardingobjectid_i").setAttribute("defaulttype", "1"); |
Well, don’t think it’s done yet! Although the above code might work most of the times, you might find it failing sometimes. Why? Because the entire DOM of Dynamics CRM 2013 is loaded in an asynchronous manner. Hence, the point where your script executes, the field “Regarding” might not have been rendered yet! Let’s add this small fix for it to work perfectly.
1 2 3 4 5 6 |
setTimeout(function() { document.getElementById("regardingobjectid_i").setAttribute("lookuptypes", "1"); document.getElementById("regardingobjectid_i").setAttribute("lookuptypeIcons", "/_imgs/ico_16_1.gif"); document.getElementById("regardingobjectid_i").setAttribute("lookuptypenames", "account:1"); document.getElementById("regardingobjectid_i").setAttribute("defaulttype", "1"); }, 1000); |
This is how it looks now.

Now, that was if you wanted to restrict a Customer lookup field to a single entity. What do you do if you want to allow multiple entities, and restrict only a few? It’s simple. See the following code to get it.
1 2 3 4 5 6 |
setTimeout(function() { document.getElementById("regardingobjectid_i").setAttribute("lookuptypes", "1,2"); document.getElementById("regardingobjectid_i").setAttribute("lookuptypeIcons", "/_imgs/ico_16_1.gif?ver=-475068199:/_imgs/ico_16_2.gif"); document.getElementById("regardingobjectid_i").setAttribute("lookuptypenames", "account:1:Account,contact:2:Contact"); document.getElementById("regardingobjectid_i").setAttribute("defaulttype", "1"); }, 1000); |
The result now is as follows with Account and Contact being the only allowed Entities.

Hi Dynamotion,
Thanks! This really helped. I was really wondering after upgrading to MSCRM 2013 how I could get this to work. (:
Hi CRM Newbie,
Glad to be of assistance.
Hey Dynamotion,
It works like a charm, you made my day!!! By the way, I really like your blog; it has got those little things that are missing elsewhere.
Cheers, Rob
Hi Rob,
I am glad you like my blog. 😀
Thanks,
Dynamotion
Not works for me 🙁 (CRM 2013 SP1)