Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Js to filter optionset.

Posted on by 240

type is a an optionset attribute. I dont want to use addoption as it will createa new optionset value everytime.

If(type==1)

{

show a,b;//a,b,c are values from another optionset

}

If(type==2)

{

show b,c;

}

*This post is locked for comments

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Js to filter optionset.

    No , its only client side changes and supported method . You can proceed  in this way.

  • NK Bhairi Profile Picture
    NK Bhairi 240 on at
    RE: Js to filter optionset.

    function OptionSetAddRemove() {

       var optionSet = Xrm.Page.ui.controls.get("new_myoptionset");

       var optionSetValues = optionSet.getAttribute().getOptions(); // retrieve All options of Option set field

       optionSet.clearOptions();

       optionSetValues.forEach(function (element) {

           if (element.value == "831260009")  // Add Options which you want to show based on value

               optionSet.addOption(element);

           if (element.value == "831260008")  // Remove options which you want to hide based on value

               optionSet.removeOption(element);

       });

    }

    optionSet.addOption(element); // Will this not create a new optionset field value every time?

  • Suggested answer
    gdas Profile Picture
    gdas 50,085 on at
    RE: Js to filter optionset.

    Hi,

    In addition you can also follow below reference -

    Using JS add/remove option-

    community.dynamics.com/.../289497

    dependent picklist -

    arunpotti.wordpress.com/.../filter-optionsets-based-on-selection-in-ms-crm-using-javascript

  • Suggested answer
    Rawish Kumar Profile Picture
    Rawish Kumar 13,756 on at
    RE: Js to filter optionset.

    Hello there,

    Looks like you need dependent optionset functionality. If you are d365 - try to use out of the box dependent optionset feature www.trellispoint.com/dependent-option-sets-updated-dynamics-365

    Otherwise In the SDK you have sample code of achieving this functionality  docs.microsoft.com/.../gg594433(v=crm.8)    

    www.mohamedibrahim.net/.../microsoft-dynamics-crm-building-developing-and-creating-multiple-dependant-pick-lists-option-sets-drop-down-menus  

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 Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans