Jul 8, 2007

Set a default entity on a lookup window

In case you have more entities to chose from on a lookup window, then you might want to be able to set the default for this lookup. For instance, the regarding field on an activity entity like letter, email and fax does support multiple entities.

If you want this to default set to contact, then use this javascript on the form onload:
//set defaultcrmForm.all.regardingobjectid.defaulttype = "2";

Even better, what if you dont want your user to be able to choose any entity and force them to use the contact entity? Then use this script:

//set only contactcrmForm.all.regardingobjectid.lookuptypes = "2";

//set iconcrmForm.all.regardingobjectid.lookuptypeIcons = "/_imgs/ico_16_2.gif";

Dont forget to set the icon. The icon will be displayed in front of the selected name after a selection in the lookup box has been made.For a custom entity, then mind that the icon does not work that easily. Use this script for custom entities:
//set only contactcrmForm.all.regardingobjectid.lookuptypes = "10003";

//set iconcrmForm.all.regardingobjectid.lookuptypeIcons = "/_imgs/icon.aspx?objectTypeCode=10003&iconType=GridIcon&inProduction=1&cache=1";

Good luck!

1 comment:

Ben Morch said...

Is this possible in CRM 2011? I am trying to set the default lookup to the Lead entity in the Appointment Regarding field.