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 365 | Integration, Dataverse...
Answered

addOption value error

(0) ShareShare
ReportReport
Posted on by 160

I'm adding options dynamically.  I have a option set field that have no items.  I'm using javascript to add options on the form onload event.  This is the option set (I added two items to show what the values look like):

pastedimage1573595773631v1.png

This is the code that I'm using to create my option object:

                         
                           var num1 = Number(451330000+ Number(_facs_userid_value);

                           console.log(num1);
                           formContext.getControl("facs_worker1").addOption(setOptionAttributes("Supervisor, Sam"num1));
                           
                           
                           function setOptionAttributes(optionTextoptionVal){
                                      var option = {text:optionTextvalue:optionVal};
                                      return option;
                            }
This is the option value in my picklist:
pastedimage1573595773632v2.png
This is my error:
pastedimage1573595773632v3.png
I'm adding the correct publisher prefix, so I'm not sure why I'm still getting this error.
I have the same question (0)
  • Verified answer
    RaviKashyap Profile Picture
    55,410 Moderator on at
    RE: addOption value error

    Hi,

    You can add options which are already exists. You cannot add any new options which does not exists in the optionset.  The screenshot is not clear but it looks l;ike you have 2 items in your optionset which means you can only add remov these options. Assuming the value for the two items you have added are 802790000, 802790001, you can add/ remove it like this:

    formContext.getControl("facs_worker1").removeOption(802790000)

    formContext.getControl("facs_worker1").addOption(setOptionAttributes("Supervisor, Sam", 802790000));

    You can refer this old thread as well for better understanding.

    community.dynamics.com/.../show-hide-options-in-optionset-value

    Hope this helps.

  • Suggested answer
    Z_Mike Profile Picture
    160 on at
    RE: addOption value error

    Hi Ravi,

    Thanks for your response.  I now understand the out of range error.

    Mike

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 365 | Integration, Dataverse, and general topics

#1
Sahan Hasitha Profile Picture

Sahan Hasitha 109

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 77 Super User 2025 Season 2

#3
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 70

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans