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.
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
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.
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
Hi,
You can open advanced find and design your query as below
Then you can download fetchXml by clicking on Download fetchXml button on top
Use this fetchXml in your javascript code
Hi,
fetchXml is in your code.
To add business unit filter and test fetchXml you can use fetchXml builder tool in xrmtoolbox
You can also use Dataverse rest builder tool
I'm very new to this can u tell me where can I find the fetch Xml?
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
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 290,522 Super User 2024 Season 2
Martin Dráb 228,441 Most Valuable Professional
nmaenpaa 101,148