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).