Defining a Lookup box in Dynamics CRM 4.0

Simon Phillips, 20 July 2010

Have you ever found the need on an activity (or any other entity for that matter) to filter the look up box options to show different entities or to default to a set entity (as it normally displays in alphabetical order making account the usual first choice)?

After several requests from customers to provide them a method to do this I was on a quest to come up with a solution. After a little bit of internet surfing and hunting around I found something that may be of some use.

if (crmForm.all.<<attribute Name>> != null) {

crmForm.all.<<attribute Name>>.setAttribute("lookuptypes", "10001, 10030, 8");

}

 

Idea and code taken from several forums code strung together by myself.

 

What this does is forces the lookup box to the set entities (the numbers).

To find out what the ‘Entity ID Number’ is, of the entities you wish to include in the lookup box, you go to the following URL “http://<<CRM URL>>/sdk/list.aspx” . This will display the following:

Just click on the desired definition button of the entity you require and it will take you to a page that has everything you could ever want to know about an entity, including the entity ID number.

The drop down list will still be ordered in alphabetical order but it will default to the first entity that you have entered. You can add as many or as few as you require.

Let me tell you now that this is an unsupported customization but it will still do the required job. One thing that you will notice is, after selecting a record the icon will not be displayed, or it will be showing the wrong icon, but this is not an issue as after the form has been saved and reloaded it will then be displayed.