Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Hide option set values

Posted on by 1,942

Hi all,

I am trying to hide the values in an options using the below library and it is working fine so far.

Xrm.Page.getControl().removeOption();

The option set is created from a global option set and seems to be an issue in hiding the values.

Any idea on to approach this?

*This post is locked for comments

  • Saddamk206 Profile Picture
    Saddamk206 777 on at
    RE: Hide option set values

    Hi,

    Also can try this:-

    for (var i = 0; i < Xrm.Page.getAttribute("FieldName").getOptions().length; i++)
    {

    Xrm.Page.getControl("FieldName").removeOption(Xrm.Page.getAttribute("FieldName").getOptions()[i].value);
    }

  • Verified answer
    tw0sh3ds Profile Picture
    tw0sh3ds 5,600 on at
    RE: Hide option set values

    Hi,

    Maybe you have this field in header? In header you have to add "header_" prefix to your field name. Here is some example:

    community.dynamics.com/.../javascript-work-with-fields-in-header-and-business-process-flow

  • Suggested answer
    Alagunellaikumar Profile Picture
    Alagunellaikumar 6,210 on at
    RE: Hide option set values

    Hi

    Could you please cross verify your values or debug it whether it hit this line or not? The above code is correct

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Hide option set values

    Also check if you have correct optionset values and proper control name.

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Hide option set values

    Hi Vighnesh,

    Your code is correct. There is no way to have an issue with this. Please refer the thread below.

    community.dynamics.com/.../187171

    Also refer this blog.

    crmdynamicblog.blogspot.in/.../remove-item-from-picklist.html

  • Vighnesh Profile Picture
    Vighnesh 1,942 on at
    RE: Hide option set values

    Hi Guido,

    It is called on load of lead record. Below is my complete code. Unfortunately i am still able to see the value.

    function hidevalues(){

    debugger;

    Xrm.Page.getControl("new_leadtype").removeOption(100000003);

    Xrm.Page.getControl("new_leadtype").removeOption(100000002);

    Xrm.Page.getControl("new_leadtype").removeOption(100000005);

    Xrm.Page.getControl("new_leadtype").removeOption(100000022);

    Xrm.Page.getControl("new_leadtype").removeOption(100000017);

    Xrm.Page.getControl("new_leadtype").removeOption(100000021);

    Xrm.Page.getControl("new_leadtype").removeOption(100000023);

    Xrm.Page.getControl("new_leadtype").removeOption(100000009);

    Xrm.Page.getControl("new_leadtype").removeOption(100000019);

    Xrm.Page.getControl("new_leadtype").removeOption(100000006);

    Xrm.Page.getControl("new_leadtype").removeOption(100000001);

    Xrm.Page.getControl("new_leadtype").removeOption(100000015);

    }

  • Suggested answer
    Guido Preite Profile Picture
    Guido Preite 54,081 Super User 2024 Season 1 on at
    RE: Hide option set values

    local and global optionsets have no difference when using the removeOption command

    of course the script will work only inside the forms where your js library is called

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,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans