locked
Dynamically Populated Option Sets in CRM 2013 RRS feed

  • Question

  • Hello,

    In my solution, I have an entity with an option set attribute that has no option values by default. A script in the entity form handles the population of the option set dropdown via .addOption. The displayed value of the attribute shows blank or "--" (for CRM 2013). The expected behavior is that when the user selects an item in the dropdown, the field value changes and then displays the selected value. Another attribute (single line of text) then gets that value for later use. This works just fine in CRM 2011.

    However, in CRM 2013, selecting a value in the dropdown does not change the displayed value of the field. Putting focus again on the dropdown shows that the default value (blank) is selected (or nothing is selected).

    I tried to modify the field value using Xrm.Page/Entity and even JQuery directly on elements to at least to display the selected text, change some attributes, etc. None of this works. It should be noted that when attaching a "change" handler in JQuery to the dropdown, it fires. When specifying a change handler for the field in the form properties, it does not fire.

    I have another idea involving creating a workflow that runs periodically or another server process/plugin to dynamically populate a global option set, and then point my entity's option set attribute to that option set. If you're wondering why a workflow, the attribute is supposed to be a list of all existing entity names in the current default solution. If for some reason entities are added/removed from the solution, my option set needs to be brought up-to-date.

    Before going down this road, I'm wondering if any of you have encountered this and how you got around it.

    Thanks!

    Friday, January 10, 2014 11:28 PM

All replies

  • Hello Rod

    Did you manage to find a solution for your mentioned problem? I am too facing the same issue.

    Any help would be appreciated.

    Thanks,

    Bhavika Patel

    Monday, March 24, 2014 1:44 PM
  • Not sure if I understand your problem or not but you can only added/remove options to/from optionset which is originally there in optionset metadata.


    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Tuesday, March 25, 2014 2:40 AM
    Moderator
  • Hello Mahender

    As Rod mentioned in his query, the option set attribute is supposed to be a list of all existing entity names in the current CRM organization . If for some reason entities are added/removed from the organization, the option set needs to be updated.

    Hence we created a blank option set attribute. Now, OnLoad of the form, we populate the option set using .addOption() method. This populates the option set, but on selection change, attribute's OnChange() is not getting triggered and also, the selected value is not visible on form.

    Below is an example of what we are trying to achieve

    http://www.powerobjects.com/blog/2012/01/25/microsoft-dynamics-crm-and-dynamic-option-sets/

    I hope I am able to explain my query in detail here.

    Any help is appreciated.

    Thanks,

    Bhavika Patel

    Tuesday, March 25, 2014 11:52 AM
  • Did you try to debug your code, also did you publish your changes ??

    Our Website | Our Blog | Follow US | My Facebook Page | Microsoft Dynamics CRM 2011 Application Design
    Make sure to "Vote as Helpful" and "Mark As Answer",if you get answer of your question.

    Wednesday, March 26, 2014 3:26 AM
    Moderator
  • I am also having this same issue - I can clear the existing field options, then populate with new options...but when I select one of these new options, it does not update the drop down control w the selected value. I have noticed that there are two things in play here, the control and the options. You can see w this code:

    var options = Xrm.Page.getAttribute("enter_field_name").getOptions();

    var control = Xrm.Page.getControl("enter_field_name");

    You can clear the existing options using "control.clearOptions();"...and repopulate using "control.addOption({value:100000000, text:"some_text"});"...

    Does the options var need to be updated as well? If so, how would this be accomplished?

    Friday, July 18, 2014 4:00 PM
  • Hi,

    Have anyone managed to find a solution for this problem? I am too facing the same issue.

    Any help on this would be appreciated.

    Thanks.

    Tuesday, July 22, 2014 7:12 AM
  • Hi,

    I have faced the same issue. Drop-down can not be populated Microsoft Dynamics CRM 2013 though it works perfectly for CRM 2011.

    I have found one solution to this as follows-

    You can insert an HTML web resource which contains the select tag (drop-down control) only. You can add the entire code in the java script function in the HTML web resource which will be executed on load of the form when HTML page is loaded.

    • Proposed as answer by P H S Friday, January 30, 2015 11:50 AM
    Thursday, January 29, 2015 7:29 AM