Quantcast
Channel: Microsoft Dynamics CRM Forum - Recent Threads
Viewing all articles
Browse latest Browse all 82002

Option sets

$
0
0

Hi I have 2 optio sets (new_type1 and new_type2). I need to do the following: depending on thevalue ofthe first  option set I need to get the secondfield with certain values ( the field must be filtered ). Here is my code:

function Type1_Type2() {

 

    var picklistOneName = "new_type1"; //name of the first picklist

    var picklistTwoName = "new_type2";  //name of the picklist with dynamic values

 

    var picklistOne = Xrm.Page.getControl(picklistOneName);

    var picklistOneAttribute = picklistOne.getAttribute();

 

    var picklistTwo = Xrm.Page.getControl(picklistTwoName);

    var picklistTwoAttribute = picklistTwo.getAttribute();

 

    var picklistOneSelectedOption = picklistOneAttribute.getSelectedOption();

 

    var picklistOneSelectedText = "";

    if (picklistOneSelectedOption != null) {

        picklistOneSelectedText = picklistOneSelectedOption.text;

    }

 

    //This "if" statement stores the original values from the dynamic picklist.

    //Very important if the user hasn't made a selection on the first picklist or if the selection changes

    if (picklistTwo.flag == true) {

        picklistTwo.clearOptions();

        var origOptions = picklistTwo.originalPicklistValues;

 

        for (var i = origOptions.length - 1; i >= 0; i--) {

            if (origOptions[i].text != "") {

                picklistTwo.addOption(origOptions[i]);  ///////////////////////////////////////////////////////////////////

            }

        }

    }

    else {

        picklistTwo.originalPicklistValues = picklistTwoAttribute.getOptions();

        picklistTwo.flag = true;

    }

 

    if (picklistOneSelectedText != null && picklistOneSelectedText != "") {

        var picklistTwoOptions = picklistTwoAttribute.getOptions();

        for (var i = picklistTwoOptions.length - 1; i >= 0; i--) {

 

            if (picklistTwoOptions[i].value != null && picklistTwoOptions[i].value != "") {

                var optionText = picklistTwoOptions[i].text;

                var optionValue = picklistTwoOptions[i].value;

 

                //BEGIN: If the picklist is set to HMO

                if (picklistOneSelectedText == "Առևտրային") {///////////////vark

                    //Remove these values

                    if (optionText == "A" || optionText == "B" || optionText == "C" ||...) {

 

                        picklistTwo.removeOption(optionValue);

 

                       // Xrm.Page.getAttribute(picklistTwoName).setValue(100000000);

                    }

                    //Xrm.Page.ui.controls.get("new_type3").setVisible(false);

 

                }

                //END: HMO Selection

 

                //BEGIN: If the picklist is set to PPO

                else if (picklistOneSelectedText == "Հիփոթեքային") {

                    //Remove these values

                    if (optionText == "K" || optionText == "L") {

                        picklistTwo.removeOption(optionValue);

                        //Xrm.Page.getAttribute(picklistTwoName).setValue(100000006);

                    }

                    Xrm.Page.ui.controls.get("new_type3").setVisible(false);

                }

                else if (picklistOneSelectedText == "D") {///vark

                    //Remove these values

                    if (optionText == "ZZZZ" || optionText == "YYYYY") {

                        picklistTwo.removeOption(optionValue);

                       // Xrm.Page.getAttribute(picklistTwoName).setValue(100000007);

                    }

 

                    Xrm.Page.ui.controls.get("new_type3").setVisible(false);

                }

                //END: PPO Selection

 

                /////////////////////////////////////////////////////////////////////////////////////////////////////////

 

                //BEGIN: If the picklist is set to PPO

                else if (picklistOneSelectedText == "XX" || picklistOneSelectedText == "XXXXXXX") {

                    //Remove these values

                if ( optionText == "BBBBB") {

                    picklistTwo.removeOption(optionValue);

                   // Xrm.Page.getAttribute(picklistTwoName).setValue(100000000);

 

                }

 

                else {

                    //Remove these values

                    picklistTwo.removeOption(optionValue);

 

                }

                //END: POS Selection

            }

        }

    }

 

}

 

 

 

In this case I get second option set field with correspondingvalues: e.g. a1, a2, a3, but when I choose a2 this value doesn't saved in the option set field.

 

Thanks.

 


Viewing all articles
Browse latest Browse all 82002

Latest Images

Trending Articles





Latest Images