Announcements
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
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,
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.
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.
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
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
André Arnaud de Cal...
294,241
Super User 2025 Season 1
Martin Dráb
232,982
Most Valuable Professional
nmaenpaa
101,158
Moderator