Tuesday, October 13, 2009

How to edit the list of entities displayed in the Look for picklist in Lookup window in MS CRM 4.0

The regarding lookup windows generally display a list of all entities that can be associated with an activity. Quite often this feature becomes quite an issue with the users always having to select the appropriate entity from the list before applying the search. The longer the list of entities the more time consuming it is to search using the lookup window.It would be a boon to have only selected entities in the list. Well this is not available for customization through the CRM customization area. But it could be done by adding the Jscript to onload of the form.

There are few properties of the Lookup control being set when we open a form and those are “Lookup Types”, “Lookup Type names” ,”Lookup Type Icons” and “default type”.

We need to over load the default settings by writing our own logic in onload of the form to load specific list of entities to show up in the Look for section.

/*Give the entity type code that you want in below script we want to show account, contact, Lead and Opportunity in order in the list */
crmForm.all.regardingobjectid.lookuptypes = "1,2,3,4";

/*Make sure you set the path of the entity images correctly for the list specified above */
crmForm.all.regardingobjectid.lookuptypeIcons = "/_imgs/ico_16_1.gif:/_imgs/ico_16_2.gif:/_imgs/ico_16_3.gif:/_imgs/ico_16_4.gif:";

/*The below script is to set default entity in the multiple entity lookup. Here we set the default entity to be Opportunity */
crmForm.all.regardingobjectid.defaulttype = "3";


Above example will show Account, Contact, Opportunity and Lead in the Look For entity list and default entity is Opportunity.

No comments: