locked
Display Contacts in form field lookup based on what Customer is chosen in a Case form RRS feed

  • Question

  • Morning All,

    I’m lookingfor some help with a custom Case creation form; I have outlined whatfunctionalities in looking for below.

    When a case is started, the user will select an Account from the ‘Customer’ field, when the ‘Customer’ has been selected, the user will click the ‘Associated Contact’ (custom) field lookup button.

    In the ‘Associated Contact’ lookup only the Contacts who have their ‘Parent Customer’ equal to the case ‘Customer’ field should be displayed.

    I would also like the option to add a new Contact from the ‘Associated Contact’ lookup box, in the new Contact form the ‘Parent Customer’ field should default to the Account in the case ‘Customer’ field.

    We have CRM 2011 on premise running on SBS 2008r2.

    Any help with this would be greatly appreciated.

    Thank you,

    Fulton.



    • Edited by Fultz Wednesday, June 20, 2012 12:43 AM
    Wednesday, June 20, 2012 12:42 AM

Answers

  • Seems like there's a typo "disablecon" instead of your full function name "disablecontact".

    Check the function calls in your onChange event of the Customer Field.

    By the way, is the name of your custom contact attribute is exactly "new_associatedcontactid" as in my sample code?

    • Marked as answer by Fultz Thursday, June 21, 2012 3:14 AM
    Thursday, June 21, 2012 2:27 AM

All replies

  • In the ‘Associated Contact’ lookup only the Contacts who have their ‘Parent Customer’ equal to the case ‘Customer’ field should be displayed.

    For this case, you have to filter your lookup dynamically onChange of the "Customer" field.

    Reference the following sample codes to achieve your requirement.

    http://crmconsultancy.wordpress.com/2011/05/17/filtered-lookups-in-crm-2011/

    http://crmdm.blogspot.com/2011/05/lookup-filtering-in-crm-2011-using.html

    http://gtcrm.wordpress.com/2011/03/22/filtered-lookup-approaches-in-crm-2011/

    I would also like the option to add a new Contact from the ‘Associated Contact’ lookup box, in the new Contact form the ‘Parent Customer’ field should default to the Account in the case ‘Customer’ field.

    For this case, either you handle this by plugin on Create/Update of the Case entity

    or you can call update request for Contact by passing the customer accountID at onSave of the Case entity.

    Here's the sample codes for Update Requests in .NET and Jscript for Microsoft Dynamics CRM 2011.

    http://mileyja.blogspot.com/2011/04/how-to-use-update-requests-in-net-and.html


    Wednesday, June 20, 2012 1:33 AM
  • Thank you Linn,

    Trying now, will keep you updated on result.

    Fulton.

    Wednesday, June 20, 2012 2:09 AM
  • Hi Lin,

    Those links have been really very helpful, I have the filter working, I think i'll leave the second part until i become more familiar with CRM 2011.

    Do you know how I would go about disabling  the ‘Associated Contact’ field if a Contact was chosen from the 'Customer' field, since our customers can be either Accounts or Contacts. 

    thanks again,

    Fult

    Wednesday, June 20, 2012 3:31 AM
  • You can use the following code at onChange of 'Customer' field.

    if (Xrm.Page.getAttribute("customerid").getValue() != null && Xrm.Page.getAttribute("customerid").getValue()[0].typename == "contact")
    	Xrm.Page.getControl("new_associatedcontactid").setDisabled(true);

    Wednesday, June 20, 2012 4:47 AM
  • Hi Linn,

    Apologies for being a pest, I have tried this without success. I am using the following code:

    function disablecontact()
    {

    if (Xrm.Page.getAttribute("customerid").getValue() != null && Xrm.Page.getAttribute("customerid").getValue()[0].typename == "contact")
    {
     
    Xrm.Page.getControl("new_associatedcontactid").setDisabled(true);

    }

    }

    This is the error i get when i change the Customer Field. I having been looking around trying to work out what is causing the problem but to no avail seems everyony has different causes.

    thank you,


    Have a good day, Fulton.

    Thursday, June 21, 2012 1:02 AM
  • Seems like there's a typo "disablecon" instead of your full function name "disablecontact".

    Check the function calls in your onChange event of the Customer Field.

    By the way, is the name of your custom contact attribute is exactly "new_associatedcontactid" as in my sample code?

    • Marked as answer by Fultz Thursday, June 21, 2012 3:14 AM
    Thursday, June 21, 2012 2:27 AM
  • Aweseome, thatnk you very much.

    You were correct, the proble was my custom field attribute was called new_associatedcontact, and I renamed function to disablecontact, all is good and works well.

    cheers mate;)


    Have a good day, Fulton.

    Thursday, June 21, 2012 3:17 AM