Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics CRM (Archived)

Add/Insert New Value into OPTIONSET

(0) ShareShare
ReportReport
Posted on by

hi all

I have created a optionset with 1 value in it, but on runtime when the user press button
i would like to add another two values in it, i can add the values and they display in the
optionset list but when i click on any newly added value it doesn't get selected and won't show

i have tried many different ways doing it but can't get it work.

can anyone help me with this please.

thanks

*This post is locked for comments

  • Suggested answer
    RE: Add/Insert New Value into OPTIONSET

    Hi, Moif.

    I think I understand your goal. You want you user to type a partial address and have CRM display the candidates for the user's input inside a contact form, right? That way, the user can just select the desired address from the dropdown and have CRM fill in the address fields on the form.

    To accomplish this, you might want to consider using HTML Web Resources embedded in the contact form using IFRAMES. I don't think a custom OptionSet will help you here. The best approach that comes to my mind right now is to have your Web Resource display an input text field, in which the user can type the partial address. When this happens, you can query your data source for the addresses (using the user's input) and populate a select element inside your Web Resource as well. Finally, when the user selects a value within your select element, you can fill in the address fields in the contact form.

    Please, let me know what you think about this possible implementation.

    Thanks,

  • Suggested answer
    Mahendar Pal Profile Picture
    Mahendar Pal 45,095 on at
    RE: Add/Insert New Value into OPTIONSET

    Hi,

    There is two things, using simple JS code, you can only add and remove only the items which is already defined in the metadata of the entity, as said by others.

    Another option is to add our options to existing option set's metadata using metadata service call using js code like below:

    // Create a request.

    InsertOptionValueRequest insertOptionValueRequest =

       new InsertOptionValueRequest

    {

       AttributeLogicalName = "new_picklist",

       EntityLogicalName = Contact.EntityLogicalName,

       Label = new Label("New Picklist Label", _languageCode)

    };

    // Execute the request.

    int insertOptionValue = ((InsertOptionValueResponse)_serviceProxy.Execute(

       insertOptionValueRequest)).NewOptionValue;

    Refer: msdn.microsoft.com/.../gg509035.aspx

    So you Can write a SOAP call, You can convert above code to client side using SOAP logger available in SDK 

    http://nishantrana.me/2014/08/27/updated-soaplogger-for-crm-2013-to-generate-javascript/

    Hope it will help.

  • RE: Add/Insert New Value into OPTIONSET

    hi all

    thank you for the replies, I am using CRM 2015 on premise, I am a new developer and don't really have much

    luck with javascript, the scenario I am working on I don't know how the OPTIONSET will work for me.

    on a add contact page, I have implemented a Address Search when a user enter postcode and search a dialog box show the list of available address.

    but the requirement is to not open a dialog box but add a dropdown list to display available address, I could not find a way to add a dropdown list, and tried using OPTIONSET but as you guys have answered it means OPTIONSET is not the solution I can use for this.

    Any advise what alternate option I can use to add a dropdown list populated with dynamic values at runtime.

    thank you all.

  • Suggested answer
    Surmeet Singh Profile Picture
    Surmeet Singh 3,075 on at
    RE: Add/Insert New Value into OPTIONSET

    Hi Moif,

    First the optionset needs to be added using configuration, then later via javascript you can show/hide the values in it.

    This may help you: social.microsoft.com/.../crm-2011-add-remove-optionset-values-based-on-another-field-value

  • Suggested answer
    RE: Add/Insert New Value into OPTIONSET

    Hi Moif,

    What CRM version are you on?

    For CRM 2015, you should use the method Xrm.Page.getControl("control-name").addOption(...) to add an option to an Option Set. Also, the options you are adding dynamically must exist in the Option Set definition. In other words, you should not add options with values that don't map to an existing option in the Option Set definition.

    Thanks,

    -- Nathan Benelli

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…

Vahid Ghafarpour – Community Spotlight

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

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,516 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,401 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans