locked
Limit customer lookup in Opportunity to Accounts only RRS feed

  • Kérdés

  • Can someone please help me limit the customer lookup on the Opportunity form to allow for selection of Accounts only.  I had this working in CRM 3.0, but that solution no longer works in 2011.

     I found the below solution in the CRM 2011 Beta forum, and I tried to tweak it to show Accounts instead of Contacts, but I can not make it work.  I need specifics, like what jscript to add as a Web Resource and then what even to place it on.  Thanks to anyone who can help!

        $("#parentcustomerid").attr("lookuptypes", "2");
        $("#parentcustomerid").attr("lookuptypenames", "contact:2");
        $("#parentcustomerid").attr("lookuptypeIcons", "/_imgs/ico_16_2.gif");
        $("#parentcustomerid").attr("defaulttype", "2");


    Jane Davis
    • Áthelyezte: Kimberlee Johnson 2011. március 21., hétfő 15:47 Jscript question (From:Dynamics CRM)
    2011. március 21., hétfő 0:11

Válaszok

  • Thank you Batistuta!!!!!

     

    Since I was using this on the Opportunity form, I had to change it slighly.  This is what worked:

     

     

    function FilteredCustomerLookupAccount()
     
    {
    //Limit the entity lookup choice to Account
    document.getElementById("customerid").setAttribute("lookuptypes", "1");
    }


    Jane Davis
    • Megjelölte válaszként: JMD30094 2011. április 19., kedd 12:09
    2011. április 19., kedd 12:09
  • Hi Jand,

         Please put this in the onload event of the CRM Form.

         document.getElementById("parentcustomerid").setAttribute("lookuptypes", "1");

        it is also an unsupported way.


    刀客 | MSN:caims#techsun.com | BLOG:http://caims.cnblogs.com | 提供微软CRM高级开发顾问外包
    2011. április 19., kedd 9:36
    Moderátor

Az összes válasz

  • Hello,

    Your solution is useful if you want to set the default option as Contact / Account. To show only the Account, you need a different approach.


    Cornel Croitoriu - Senior Software Developer & Entrepreneur

    If this post answers your question, please click "Mark As Answer" on the post and "Mark as Helpful"

    Biz-Forward.comCroitoriu.NET

    2011. március 22., kedd 8:39
  • Can you please help me with an example of that different approach?
    Jane Davis
    2011. március 23., szerda 17:53
  • Hi Jane,

    Please put this in the onload event of the CRM Form.

    crmForm.all.customerid.setAttribute("defaulttype", "1");
    crmForm.all.customerid.setAttribute("lookuptypes", "1");

    Thanks and Regards

    Ramu

    2011. március 23., szerda 19:15
  • Unfortunately, this no longer works in CRM 2011.  Even if you convert it to the CRM 2011 object model, it does not work.
    Jane Davis
    2011. március 23., szerda 21:19
  • Hi Jand,

         Please put this in the onload event of the CRM Form.

         document.getElementById("parentcustomerid").setAttribute("lookuptypes", "1");

        it is also an unsupported way.


    刀客 | MSN:caims#techsun.com | BLOG:http://caims.cnblogs.com | 提供微软CRM高级开发顾问外包
    2011. április 19., kedd 9:36
    Moderátor
  • Thank you Batistuta!!!!!

     

    Since I was using this on the Opportunity form, I had to change it slighly.  This is what worked:

     

     

    function FilteredCustomerLookupAccount()
     
    {
    //Limit the entity lookup choice to Account
    document.getElementById("customerid").setAttribute("lookuptypes", "1");
    }


    Jane Davis
    • Megjelölte válaszként: JMD30094 2011. április 19., kedd 12:09
    2011. április 19., kedd 12:09
  • Adding this code to the form onload WILL work to default the customer lookup to account and disable the option to select a contact; HOWEVER, if you have saved the record and then go back to try to modify the field to select a DIFFERENT account, the field will be cleared and not allow you to select a new account.

    Removing the function from the onload event and adding it to the onchange event of the field will reslove this issue.

    2012. április 17., kedd 13:15
  • Hi,

    Add the function to the onChange event of the field instead doesn't seem right to me. At first the user will be able to pick up a contact instead of an account, and only then the script will load.

    I didn't manage to replicate the issue you have highlighted.

    I added the code in the onLoad event of the form and it works properly.


    MCC, MCT, MCP, MCTS
    If you find this post helpful then please "Vote as Helpful" and "Mark As Answer".

    2012. április 23., hétfő 12:22
  • //Jeromie Kirchoff
    //This is input for OnLoad also can be used on OnChange/OnSave
    //Might have to use the ForceSubmit function if you recieve any errors when saving
    //Accounts Only
    crmForm.all.customerid.setAttribute("lookuptypes", "1");
    //Contacts Only
    crmForm.all.customerid.setAttribute("lookuptypes", "2");
    //Leads Only
    crmForm.all.customerid.setAttribute("lookuptypes", "4");
    //Accounts, Contacts & Leads
    crmForm.all.customerid.setAttribute("lookuptypes", "1,2,4");
    2013. március 26., kedd 22:17