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

9 Comments

  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

    crmForm.all.customerid.getAttribute(‘address_city’);

    Thanks

  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. megan fox said,

    September 11, 2009 at 8:50 pm

    Sign: umsun Hello!!! rcuwwymhyw and 2817ssgfhphzye and 4290Cool!

  6. 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″);

  7. 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

    Debby

    • 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.


Post a Comment