I wrote a code for getting multi select options for security role while selecting specific records and saving the details I'm getting this error.
One or more of the option values for this picklist are not in the range of allowed values.
My code:
function getRole(executionContext)
{
debugger;
var fetchXml = "?fetchXml=<fetch mapping='logical'><entity name='role'><attribute name='roleid'/><attribute name='name'/></entity></fetch>";
Xrm.WebApi.retrieveMultipleRecords("role", fetchXml).then(
function success(result) {
var formContext=executionContext.getFormContext();
var optionCode=formContext.getControl("gab_securityrole");
//optionCode.clearOptions();
var optionKey=10000;
for (var i=0;i<result.entities.length;i++) {
var Name=result.entities[i].name;
var obj={};
obj["text"]=Name;
obj["value"]=optionKey;
optionCode.addOption(obj);
optionKey++;
}
},
function (error){
alert(error.message);
}
)
};
Please do respond to my query