locked
Dependencies pick list RRS feed

  • Question

  • Hi,

    I have created two fields in Contact entity..

    one is City - option set - hyd, banglore, delhi, California, New York.. 

    another is Country - option set - India, USA 

    *  hyd, banglore, delhi come under country "India"

     * California, New York.. come under country "USA"

    I need to write javascript so that if i select one of the cities that is hyd, banglore, delhi , then india should get automatically selected.. 

    and if i select one of the cities calfornia or new york then USA should get selected automatically ..

    PLEASE SUGGEST ME USING JAVASCRIPT 

    Monday, January 27, 2014 5:32 AM

Answers

  • hi

    try this

    function picklist_onchange() {
        
        var cityText = Xrm.Page.getAttribute("City").getText();
        
        var countryText = Xrm.Page.ui.controls.get("Country");
        
        var optionsSets = countryText.getAttribute().getOptions();
       
        countryText.clearOptions();

        if (cityText == 'Hyd') {
            countryText.addOption(optionsSets[0], 1);  //[0] is the sequence no. of country optionset for india value          
        }
        else if (cityText == 'Delhi') {
            subIndustry.addOption(optionsSets[0], 1);          
        }
       else if (cityText == 'New York') {
            subIndustry.addOption(optionsSets[1], 1);         
        }
    }

    Hope this helps..

    • Marked as answer by Amy.4 Monday, January 27, 2014 8:08 AM
    Monday, January 27, 2014 6:57 AM

All replies

  • Hello,

    Please check this it will help you for your requirement.


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Monday, January 27, 2014 5:41 AM
    Moderator
  • Hi 

    Check the below links..

    http://charanmandya.blogspot.in/2013/03/dependent-picklist-CRM-2011.html

    http://crmdm.blogspot.in/2011/02/how-to-filter-picklist-based-on-another.html

    Hope this helps..

    Monday, January 27, 2014 6:01 AM
  • Thanks for the reply.. but i have already suceeded in implementing this .. my exact requirement is vice versa(showing country on selection of any city) to this.. 

    MY REQUIREMENT IS, 

    If i select any one of the 3 cities(HYD,BANGLORE,DELHI) then India should be diaplayed

    and in the same way if i select any of the two cities either (California or New York) then USA should be displayed...

    Monday, January 27, 2014 6:48 AM
  • hi

    try this

    function picklist_onchange() {
        
        var cityText = Xrm.Page.getAttribute("City").getText();
        
        var countryText = Xrm.Page.ui.controls.get("Country");
        
        var optionsSets = countryText.getAttribute().getOptions();
       
        countryText.clearOptions();

        if (cityText == 'Hyd') {
            countryText.addOption(optionsSets[0], 1);  //[0] is the sequence no. of country optionset for india value          
        }
        else if (cityText == 'Delhi') {
            subIndustry.addOption(optionsSets[0], 1);          
        }
       else if (cityText == 'New York') {
            subIndustry.addOption(optionsSets[1], 1);         
        }
    }

    Hope this helps..

    • Marked as answer by Amy.4 Monday, January 27, 2014 8:08 AM
    Monday, January 27, 2014 6:57 AM