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


  1. mesgur said,

    February 2, 2008 at 1:57 pm

    This is very good. But i have another question about lookup fields.
    I want to specify which entities can be chosen for lookup fields. How can I do choosing just account values for “Potential Customer” field on Opportunity form? So i should disable contact or other entities both form assistant and lookup window for lookup fields. Is there a method like “setAttribute” to do this.
    Thank you.

  2. uMar Khan said,

    February 3, 2008 at 2:55 am

    Here we go. Add following line in onLoad of opportunity entity form. It will work for atleast the lookup window.

    crmForm.all.customerid.setAttribute(“lookuptypes”, “1”);

  3. Katyc said,

    February 24, 2008 at 3:47 am

    I need get other attribute the lookup field. It is possibl



  4. sandrar said,

    September 10, 2009 at 8:03 pm

    Hi! I was surfing and found your blog post… nice! I love your blog. 🙂 Cheers! Sandra. R.

  5. Debby said,

    November 6, 2009 at 12:04 pm

    Is this now supported in Microsoft CRM 4.0?

    • uMar Khan said,

      November 6, 2009 at 12:36 pm

      It’s changed, following will work for you in CRM 4:

      crmForm.all.customerid.setAttribute(“lookuptypes”, “2”);

  6. Debby said,

    November 12, 2009 at 12:19 am

    Thanks for the CRM 4.0 version of the script but as per our rules and regulations at the Company, we may only use MS supported Jscripts. So will Microsoft accept this as a supported script or is it still regarded as unsupported?

    Many Thanks


    • uMar Khan said,

      November 12, 2009 at 9:24 am

      Its unsupported. But you can always document the unsupported customisations and when required, you can simply remove them for support purposes.

      • Debby said,

        November 12, 2009 at 7:08 pm

        Thank you very much for clearing this up with me. Much appreciated. Great site you got going here …… Debby

  7. Thomas said,

    April 7, 2011 at 10:58 pm

    Hi, I have been using this one for 4.0 for a long while now.

    Have you found this for 2011 yet? Thank you..

  8. March 27, 2013 at 8:10 am

    crmForm.all.customerid.setAttribute(“lookuptypes”, “1,2,4”);

    This will give you access to all 3. Accounts/Contacts/Leads in order of the number you put first.

  9. jalalhussain.H said,

    May 11, 2013 at 3:37 pm

    iam new to mscrm,i have the functionality to develop global search across in mscrm ,can u pls provide me solution for this .


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: