web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Filtering option set fields

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Suggested answer
    Aric Levin - MVP Profile Picture
    30,190 Moderator on at

    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.

  • Suggested answer
    gdas Profile Picture
    50,091 Moderator on at

    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
                    }
                });
            }


     

  • Community Member Profile Picture
    on at

    Thanks Aric, I will look into this.

  • Community Member Profile Picture
    on at

    Thanks Goutam also.

  • Suggested answer
    sandeepstw Profile Picture
    4,601 on at

    Hi,

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

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

  • Mitchell M Profile Picture
    10 on at

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

  • TT72 Profile Picture
    5 on at

    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]

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

News and Announcements

Season of Giving Solutions is Here!

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#2
SA-08121319-0 Profile Picture

SA-08121319-0 2

#2
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans