web
You’re offline. This is a read only version of the page.
close
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

I have the same question (0)
  • Suggested answer
    NathanBenelli Profile Picture
    on at

    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

  • Suggested answer
    Surmeet Singh Profile Picture
    3,075 on at

    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

  • Community Member Profile Picture
    on at

    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
    Mahendar Pal Profile Picture
    45,095 on at

    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.

  • Suggested answer
    NathanBenelli Profile Picture
    on at

    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,

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics CRM (Archived)

#1
SA-08121319-0 Profile Picture

SA-08121319-0 4

#1
Calum MacFarlane Profile Picture

Calum MacFarlane 4

#3
Alex Fun Wei Jie Profile Picture

Alex Fun Wei Jie 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans