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.
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
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.
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);
}
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.
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?
Make a html webresource which internally fetches option set , sets it but only show the ones you want in your select control.
André Arnaud de Cal...
291,969
Super User 2025 Season 1
Martin Dráb
230,842
Most Valuable Professional
nmaenpaa
101,156