Hi All,
I have an requirement that i need to check the duplicate rank in an table data for that i used the Javascript. Onchange of the field i'm calling the below async function. But unable to read value from the array of result. Result is the constant where i'm storing results from retrieve multiple records.
Please refer below code:
async function SetHierarchyrank(executionContext) {
var formContext = executionContext.getFormContext();
var id = formContext.getAttribute("sysia_approvalpath").getValue()[0].id.replace("}", "").replace("{", "");
var regexp = /^[0-9]+$/;
let rank_no = formContext.getAttribute("sysia_rank").getValue();
var rank=rank_no.toString();
if (rank_no.search(regexp) == -1) {
formContext.getControl("sysia_rank").setNotification("Only Numbers allowed");
}
else{
let options =`?$select=sysia_approvalhierarchyid,sysia_rank&$filter=_sysia_approvalpath_value eq '${id}'`;
const multipleRslt = await Xrm.WebApi.retrieveMultipleRecords("sysia_approvalhierarchy", options)
alert("count"+multipleRslt.entities.length);
if(multipleRslt.entities.length>0)
{
int lnt=multipleRslt.entities.length;
console.log(multipleRslt.entities);
for(int i=0;i<multipleRslt.entities.length;i++)
{
let entity = multipleRslt.entities[i];
console.log(multipleRslt.entities[i]);
alert("count"+entity.sysia_rank);//getting error in this line
alert("count"+rank);
}
}
}
}
please help me to achieve this.
Hi Abhilash,
Your code seems correct beside some syntax error(change int to var).
When execute this line console.log(multipleRslt.entities[i]);, could you get different value of sysia_rank field in each entity?
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... 291,240 Super User 2024 Season 2
Martin Dráb 230,149 Most Valuable Professional
nmaenpaa 101,156