Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Error code: 0x8004431a

Posted on by 100

So i am going to paste the code below along with error message.


function func(executionContext)
{
var formContext = executionContext.getFormContext();
var dname = formContext.getAttribute('new_divisionname');
var dnameValue = dname.getValue();
var classNameOptionSet = formContext.getControl('new_classname');
var classNumberOptionSet = formContext.getControl('new_classnumber');
if( dnameValue != null )
{
    var dnameGUID = dnameValue[0].id;
    Xrm.WebApi.online.retrieveRecord("account", dnameGUID, "?$select=new_classname2,new_classname3,new_classname4,new_classnumber2,new_classnumber3,new_classnumber4").then(
    function success(result) {
          var ClassName2 = result['new_classname2'];
          var ClassName3 = result['new_classname3'];
          var ClassName4 = result['new_classname4'];
          var ClassNumber2 = result['new_classnumber2'];
          var ClassNumber3 = result['new_classnumber3'];
          var ClassNumber4 = result['new_classnumber4'];
          if (classNameOptionSet == null || classNameOptionSet != null) {
                        var obj1 = {};
                        obj1['text'] = ClassName2;
                        obj1['value'] = 10;
                        classNameOptionSet.addOption(obj1);//add to option set field
                        var obj2 = {};
                        obj2['text'] = ClassName3;
                        obj2['value'] = 11;
                        classNameOptionSet.addOption(obj2);//add to option set field
                        var obj3 = {};
                        obj3['text'] = ClassName4;
                        obj3['value'] = 12;
                        classNameOptionSet.addOption(obj3);//add to option set field
            }
          if (classNumberOptionSet == null || classNumberOptionSet != null) {       
                       var obj4 = {};
                        obj4['text'] = ClassNumber2;
                        obj4['value'] = 10;
                        classNumberOptionSet.addOption(obj4);//add to option set field
                        var obj5 = {};
                        obj5['text'] = ClassNumber3;
                        obj5['value'] = 11;
                        classNumberOptionSet.addOption(obj5);//add to option set field
                        var obj6 = {};
                        obj6['text'] = ClassNumber4;
                        obj6['value'] = 12;
                        classNumberOptionSet.addOption(obj6);//add to option set field
            }
         
          },
    function (error) {
           Xrm.Utility.alertDialog(error.message);
         }
      );
}
else
var clear = formContext.getControl('new_classname').clearOptions();
var clearIt = formContext.getControl('new_classnumber').clearOptions();
}

Error Message :

Error code: 0x8004431a.

One or more of the option values for this picklist are not in the range of allowed values.
I feel like the problem is when i set the value for Objects{objs).


 

  • Z_Mike Profile Picture
    Z_Mike 160 on at
    RE: Error code: 0x8004431a

    Hi Madalina,

    I'm adding options dynamically, also.  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):

    pastedimage1573077193496v1.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:
    pastedimage1573077764599v4.png
    This is my error:
    pastedimage1573077685909v3.png
    How do I add a value that is within range?
  • Suggested answer
    RE: Error code: 0x8004431a

    Hello Kashyap,

    Yes, that is indeed the case, the value above represents the PicklistValueOutOfRange.

    By default for a custom optionset you will have this error if you will try to set them to 1, 2...

    pastedimage1572606411530v1.png

    My recommendation is to verify your prefix for your publisher from Settings->customizations->publishers and open the one used during the creation of that specific optionset and verify its value on this specific cell:

    pastedimage1572606563508v3.png

    The name of the cell is "Option Value Prefix" in case the screenshot is not clear.

    And also verify the optionset values by opening them one by one and checking the following parameter:

    pastedimage1572606682863v4.png

    The values you will use during the set addOption should match with the optionset values not with the labels.

    I hope this helps.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,280 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans