web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Removing options from Optionset

(0) ShareShare
ReportReport
Posted on by 1,299

Hi,

We have a option set with a list of product category which is in the opportunity form, we are discontinuing one of the product category so i am trying to remove the product category in the option set. But when i do it all the opportunities created earlier which had the product category that i have removed is also changed and there by returning to Null, is there a way to overcome this.

 I want all the opportunity which had the old account category to stay that way but the same account category should not be visible for the new opportunities that are created.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Community Member Profile Picture
    on at
    RE: Removing options from Optionset

    Hide that option from the dropdown using javascript on load of the form. Follow the below link

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

  • Davyjones Profile Picture
    1,299 on at
    RE: Removing options from Optionset

    Is there another way of doing this, i would not like to write scripts as there are already many

  • Joe Gill Profile Picture
    on at
    RE: Removing options from Optionset

    Hi Davy,

    The solution Vikas suggest is the only way (or a variation on it)

    Unfortunately there is no Active type flag for option sets

    Joe

  • Suggested answer
    Sanjaya Prakash Pradhan Profile Picture
    2,745 User Group Leader on at
    RE: Removing options from Optionset

    Dont worry.

    I hope you are a dynamics crm technical person. So I suggest, dont remove the optionset item from the field. if you have removed the add the item again with the same value and save publish. Now the next step is go to opportunity entity and write a form script code on Form Load event to hide the category option of the field while the opportunity for is open.

    Use the below code in form load of opportunity which will work for you.

    NOTE : Use your field name and optionset value correctly. i have used dummy values

    // JScript source code

    function Opportunity_Form_OnLoad() {

    if (Xrm.Page.ui.getFormType() != 1) {

    // Disable the field if the opporunity form is CREATE Mode

    Xrm.Page.ui.controls.get("productcategory").setDisabled(true);

    }

    else {

    //If Create Form

    Xrm.Page.getControl('productcategory').removeOption(100000004);

    }

    }

  • Saddamk206 Profile Picture
    777 on at
    RE: Removing options from Optionset

    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);
    }

  • Joseph Melillo Profile Picture
    125 on at
    RE: Removing options from Optionset

    Hi Saddam,

    I have tried almost all the JavaScripts suggested and I am not getting anywhere. I am trying to hide multiple option in an option field. Example: account form "Nature of business" Options retail, manufacture, plumber. I am trying to hide Manufacture. The JaveScript you provided, I do not have an way to add value of the option only the name of the field. did I miss something?

    Joseph

  • Saddamk206 Profile Picture
    777 on at
    RE: Removing options from Optionset

    Hi joseph.

    Sorry for late reply. Please tell me ,what exact issue you are facing.

    Are you trying in Multiselect optionset or in normal option set. Add screenshot for more clearification.

  • Joseph Melillo Profile Picture
    125 on at
    RE: Removing options from Optionset

    Hi Saddam,

    I was referring to you suggested JavaScript:

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

    {

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

    }

    It did not specified where you would input the value of the option. No big deal, I have figured out a script that works for

    function HideOption(){

    Xrm.Page.getControl("Name of option field").removeOption("value of option");

    }

    Thanks,

    Joe

  • Saddamk206 Profile Picture
    777 on at
    RE: Removing options from Optionset

    Joseph

    Both code are almost common. I have puted a dynamic code.

    Your code is also correct. I think you was facing issue with some little mistake on your code.

    Ok but now you got the solution.

    Thanks

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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
Community Member Profile Picture

Community Member 2

#1
HR-09070029-0 Profile Picture

HR-09070029-0 2

#1
UllrSki Profile Picture

UllrSki 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans