How to change the default entity in LOOKUP window?

For instance, in Opportunity form of Microsoft CRM you want to change the “Potential Customer” field’s default entity from Account to Contact. You need to use the following piece of code in onLoad event of the Opportunity Form.

if ( crmForm.all.customerid != null )
    crmForm.all.customerid .setAttribute(”defaulttype”, “2″);

Remember to enable the event and then save and publish the opportunity entity.

 Following are codes of basic entities of Microsoft CRM 3 ;

  • Account    1
  • Contact     2
  • Lead         4