Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Filtering option set fields

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

So the scenario is as follows:

Field 1 is called Category and it consists of 6 option set values and it has been designed as an Option Set.

Field 2 is called Sub-Category and for every one of the option set values chosen in Field 1, there are a minimum of 5 options they can choose from Field 2.

The data looks like this:

Sewing Machine Machine 1
Machine 2
Machine 3
Machine 4
Machine 5
Thread Thread 1
Thread 2
Thread 3
Thread 4
Thread 5

On my form Quote Product and Order Product, how do I allow the user to only see the associating options according to which Category they have chosen. When selecting Sewing Machine, in the Sub-Category only Machine 1 -5 should appear.

At any given time, the user will only have 1 Sewing Machine and 1 Thread meaning its a 1-1 relationship between the Category and Sub-Category field.

Thanks

*This post is locked for comments

  • TT72 Profile Picture
    TT72 5 on at
    RE: Filtering option set fields

    Yes, element.value did the trick for me as well.

    [quote user="Mitchell M"]

    For me I had to use optionSet.removeOption(element.value);  Thanks for your contribution.

    [/quote]
  • Mitchell M Profile Picture
    Mitchell M 10 on at
    RE: Filtering option set fields

    For me I had to use optionSet.removeOption(element.value);  Thanks for your contribution.

  • Suggested answer
    sandeepstw Profile Picture
    sandeepstw 4,601 on at
    RE: Filtering option set fields

    Hi,

    You can do using dependable option set, follow this link -

    thabisomotloung.wordpress.com/.../dependent-option-sets-in-ms-crm-2015

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Filtering option set fields

    Thanks Goutam also.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Filtering option set fields

    Thanks Aric, I will look into this.

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Filtering option set fields

    Hi ,

    How many option-set value you have in subcategory field  ? If you have more than 10 options I would suggest go for OOB dependent lookup.

    Here is the sample reference of dependent lookup -

    https://www.powerobjects.com/2016/03/15/how-to-use-dependent-lookups-for-dynamics-crm-201320152016/

    http://crmadminassist.com/microsoft-dynamics-crm-dependent-lookups/

    https://www.youtube.com/watch?v=-3OmgW_MYlM

    If you want to use optionset you can also check below reference -

    https://msdn.microsoft.com/en-us/library/gg594433.aspx

    In addition you can also write simple JavaScript based on your category value and add remove subcategory optionset options.

            // Register the function in onchange of your parent optionset
            function OnChangeCategoryOptions() {
                var optionSetCategoryVal =  Xrm.Page.getAttribute("new_category").getSelectedOption().value;
                var optionSet = Xrm.Page.ui.controls.get("new_subcategory");
                var optionSetValues = optionSet.getAttribute().getOptions();
                optionSet.clearOptions();
                optionSetValues.forEach(function (element) {
                    if (optionSetCategoryVal == "1") {
                        if (element.value == "831260001" || element.value == "831260002" || element.value == "831260003" || element.value == "831260004" || element.value == "831260005" )
                            optionSet.addOption(element);
                        else(element.value == "831260007" || element.value == "831260008" || element.value == "831260009" || element.value == "831260010"|| element.value == "831260011"  )
                            optionSet.removeOption(element);
                    }
                    else if(optionSetCategoryVal == "2")
                    {
                        // do same logic
                    }
                });
            }


     

  • Suggested answer
    Aric Levin Profile Picture
    Aric Levin 30,188 on at
    RE: Filtering option set fields

    Did you take a look at Dependent Optionset Generator from Guido Preite:

    crmoptionsets.azurewebsites.net

    This should allow you to configure what you are looking for.

    Hope this helps.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans