locked
Option Set filtering Based on Two other Option Sets RRS feed

  • Question

  • Hi,

    I have requirement like:

    Option set (A), Option set (B), Option set (C) and i need to filter Option set (C) based on Option set (A) and (B)

    for ex: IF Option set (A)-111 then Option set (B) should filter to -222 based on these two parent Option sets the Dependent Option set (C) should be filtered and shown the appropriate value.

    Thanks in Advance

    Thursday, February 28, 2013 11:10 AM

Answers

  • Hi,

    You have at least two options:

    Hope this helps.
    If i answered your question, please mark the response as an answer and also vote as helpful.

    Pedro Azevedo Crm Specialist 4.0\2011

    Thursday, February 28, 2013 11:21 AM
  • Use the below code:

    function OnChange() {
        var optionsetControl = Xrm.Page.ui.controls.get("brd_statusreason");
        var options = optionsetControl.getAttribute().getOptions();
        var type = Xrm.Page.getAttribute("brd_status").getValue();
            // 'Active' is selected
            if (type == 172100000) {
                optionsetControl.clearOptions(); 
                for (var i = 0; i < options.length - 1; i++) {
                    if (i == 0 || i == 1 || i == 2) {
                        optionsetControl.addOption(options[i]);
                    }
                }
            }
            // 'Resolved' is selected
            else if (type == 172100001) {
                optionsetControl.clearOptions();
                for (var i = 0; i < options.length - 1; i++) {
                    if (i == 3 || i == 4) {
                        optionsetControl.addOption(options[i]);
                    }

                }
            }
            // 'Cancelled' is selected
            else if (type == 172100002) {
                optionsetControl.clearOptions();
                optionsetControl.addOption(options[5]);
            }
     }

    The mentioned snippet is used to filter status reason based on the value of the status. You could get your second option set also, and based on the values of the two option sets add and remove the options of the third option set.

    It works very good! BTW, do not forget to add similar script to on load of the form! You should have two functions! One works on load of the form and do not change until a value changes. Second on change of the desired option set!


    If the answer helped you, remember to mark it as answer.

    Thursday, February 28, 2013 1:11 PM
    Moderator

All replies

  • Hi,

    You have at least two options:

    Hope this helps.
    If i answered your question, please mark the response as an answer and also vote as helpful.

    Pedro Azevedo Crm Specialist 4.0\2011

    Thursday, February 28, 2013 11:21 AM
  • Use the below code:

    function OnChange() {
        var optionsetControl = Xrm.Page.ui.controls.get("brd_statusreason");
        var options = optionsetControl.getAttribute().getOptions();
        var type = Xrm.Page.getAttribute("brd_status").getValue();
            // 'Active' is selected
            if (type == 172100000) {
                optionsetControl.clearOptions(); 
                for (var i = 0; i < options.length - 1; i++) {
                    if (i == 0 || i == 1 || i == 2) {
                        optionsetControl.addOption(options[i]);
                    }
                }
            }
            // 'Resolved' is selected
            else if (type == 172100001) {
                optionsetControl.clearOptions();
                for (var i = 0; i < options.length - 1; i++) {
                    if (i == 3 || i == 4) {
                        optionsetControl.addOption(options[i]);
                    }

                }
            }
            // 'Cancelled' is selected
            else if (type == 172100002) {
                optionsetControl.clearOptions();
                optionsetControl.addOption(options[5]);
            }
     }

    The mentioned snippet is used to filter status reason based on the value of the status. You could get your second option set also, and based on the values of the two option sets add and remove the options of the third option set.

    It works very good! BTW, do not forget to add similar script to on load of the form! You should have two functions! One works on load of the form and do not change until a value changes. Second on change of the desired option set!


    If the answer helped you, remember to mark it as answer.

    Thursday, February 28, 2013 1:11 PM
    Moderator
  • http://www.madronasg.com/blog/dependent-option-sets-crm-2011#.US-AZTD-WAQ

    https://community.dynamics.com/crm/b/crmukblog/archive/2010/12/02/crm-2011-dependent-option-set-example.aspx#.US-AnDD-WAQ

    http://blog.sonomapartners.com/2011/06/simple-javascript-to-create-dynamic-cascading-picklists-in-microsoft-crm-2011.html


    ms crm

    Thursday, February 28, 2013 4:07 PM