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 :
Customer experience | Sales, Customer Insights,...
Answered

I'm getting error while saving the details

(0) ShareShare
ReportReport
Posted on by 5

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

I have the same question (0)
  • Verified answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: I'm getting error while saving the details

    Hi,

    Do you have multiple Business unit in your system?

    If yes then you will get duplicate role name for each BU.

    For example Role name is salesperson and BU is Bu1 &BU2

    So in your results you will see two record .

    You should modify your fetchXml to add filter condition for Business Unit

    Try running fetchXml in advanced find to see the result for yourself

  • Divya Mahanthi Profile Picture
    5 on at
    RE: I'm getting error while saving the details

    I'm very new to this can u tell me where can I find the fetch Xml?

  • Verified answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: I'm getting error while saving the details

    Hi,

    fetchXml is in your code.

    To add business unit filter and test fetchXml you can use fetchXml builder tool in xrmtoolbox

    https://fetchxmlbuilder.com/

    You can also use Dataverse rest builder tool

    carldesouza.com/.../

  • Verified answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: I'm getting error while saving the details

    Hi,

    You can open advanced find and design your query as below

    IMG20221021172251.jpg

    Then you can download fetchXml by clicking on Download fetchXml button on top

    Use this fetchXml in your javascript code

  • Divya Mahanthi Profile Picture
    5 on at
    RE: I'm getting error while saving the details

    can you rectify the code and send it to me im using this java script in form properties so I dont have any idea about this tools please do help me with this

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at
    RE: I'm getting error while saving the details

    Hi,

    As discussed on call, your multi select optionset field does not have any option added.

    Your javascript code will work only when you have option added .

    If you want to add option to your multi optionset then you can write one time console application using c# to dynamically add option.

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…

Pallavi Phade – Community Spotlight

We are honored to recognize Pallavi Phade as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 107 Super User 2025 Season 2

#2
MVP-Daniyal Khaleel Profile Picture

MVP-Daniyal Khaleel 89

#3
#ManoVerse Profile Picture

#ManoVerse 58

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans