Skip to main content

Notifications

Microsoft Dynamics CRM (Archived)

Hide/Disable a selectable value in an Option List

(0) ShareShare
ReportReport
Posted on by 100

I have an Option List that is populated with Years.  As a year expires, I'd like to remove it from being selected from the Option List.  I'd like this value to continue to display on historical records, but I seem to be having great difficulty in making this happen.

  • Removing it the actual Option set seems to remove the reference to the "2014" label, so historical records show up as blank.  This is not acceptable.'
  • Utilizing the Javascript solution of Xrm.Page.getControl('field name').removeOption(value); also seems to come with the drawback that when viewing this a historical via the Form...it also blanks out the field making look like it was never set.  Not really acceptable.
  • I've tried to utilize unsupported javascript to select the particular Options that I want to remove and remove them.  I've gotten it to work for IE10, but cannot seem to get it to correctly run in IE9.  It doesn't seem to understand which frame to look in.
    • function FilterFiscalYear(){ $("select[attrName='sgs_fiscalyear'] option[title='2014']").each( function() { $(this).remove(); });}

I'm entirely baffled as to why it's so difficult to remove an option from an Option set, but leave the historical data displaying that value that's no longer selectable.

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Hide/Disable a selectable value in an Option List

    I ended up making a custom entity and then replaced the Picklist with a Lookup to the custom entity.  This would let me disable records so they were no longer selectable, but retained their value for historical reporting.

  • Saddamk206 Profile Picture
    Saddamk206 777 on at
    RE: Hide/Disable a selectable value in an Option List

    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
    Deepesh161 Profile Picture
    Deepesh161 6,317 on at
    RE: Hide/Disable a selectable value in an Option List

    No, I am suggesting to fetch option set values in html webresourcr(keep it hidden on form).

    You will also know current year in script.

    Build a dynamic select control in html (show all years except current one)

    Reference to form a dynamic select control: http://stackoverflow.com/questions/7340644/dynamically-add-input-type-select-with-options-in-javascript

    When somebody changes selection in your resource on the background set your option set.

    Hope it is more clear now.

  • Kelly Grant Profile Picture
    Kelly Grant 100 on at
    RE: Hide/Disable a selectable value in an Option List

    Thanks for your quick reply.  Can you provide any examples of how to do this?  I'm not quite following what you've recommended.

    Are you recommending that I use Jscript to clear the Option Set.  Query the Options I want.  And then use  Xrm.Page.getControl('field name').addOption(value,index) to populate the Option Set with my desired list?

  • Suggested answer
    Deepesh161 Profile Picture
    Deepesh161 6,317 on at
    RE: Hide/Disable a selectable value in an Option List

    Make a html webresource which internally fetches option set , sets it but only show the ones you want in your select control.

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Announcing Forum Attachment Improvements!

We're excited to announce that attachments for replies in forums and improved…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,969 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,842 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans