We use option sets quite often. Regularly I get asked to change the values of these as business requirements change.
Is there a way to disable an option set value, or hide a value that is no longer available to use?
Eg.
Option B is no longer available. Deleting 'Option B' will delete this value from records already using this value, which I do not want to happen.
A quick fix would be to write 'DO NOT USE - Option B', but this looks messy.
Has anybody got a solution for this.
Thanks in advance.
*This post is locked for comments
Can you please let me know how?
Hi Ang111,
You can not do it other than JS.
If I answer your question then please mark it as verified.
Let me know if I can provide you with more details.
Thanks
Regards,
Abdul Wahab
Power Platform & Customer Engagement Developer/Lead/Solution Architecture/Project Manager
Direct/WhatsApp:+923323281237
E-mail: abdulwahabubit@outlook.com
Skype: abdul.wahabubit
Linkedin: www.linkedin.com/.../
Hi,
I have the same inquiry, can I do it somehow else other than using JavaScript?
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);
}
Example use Xrm.Page.getControl(..).addOption :
var low = {value : 100000000, text : "Low"}; var medium = {value : 100000001, text : "Medium"}; var high = {value : 100000002, text : "High"}; var pickList = Xrm.Page.getControl("control_name"); var options = pickList.getOptions(); for (var i = 0; i < options.length; i++) pickList.removeOption(options[i].value); pickList.addOption(low); pickList.addOption(medium); pickList.addOption(high);
If you are constantly being asked to hide values or change, the best approach for this (no code) would be to create the option set as an entity (ENTITY A) and create the values as records (OPTION A, OPTION B, OPTION C). Then on the record where you have the option set, create a lookup to the custom entity (ENTITY A). So when records no longer need to be visible, you can just deactivate the record (which will not remove reference to existing records) and when the user clicks on the lookup view they only see active records.
Thanks
Sukh
You can interact with fields in the business process flow using JavaScript. I describe how to do it in this post ...
neilparkhurst.com/.../javascript-work-with-fields-in-header-and-business-process-flow
You can also (if required) have onchange or onselect events for the stages in you business process flow. Again I describe that here;
neilparkhurst.com/.../javascript-add-code-on-business-process-flow-change-and-select
And logic for adding / removing fields from the optionset is described here;
It's not ideal, but in a similar circumstance we decided to just put the options into an entity and have a lookup, rather than do an option set. That way we could disable/re-enable them, make notes about why, etc...
Like the JS option but the problem if you're using a Business Process Flow to capture the Optionset. The JS won't work on the BPF. Anyone come up with any creative ideas for this?
Hi,
Do you mind using JS? If not, use code written below on page OnLoad.
Xrm.Page.getControl("optionsetfieldschemaname").removeOption("OptionsetValue").
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156