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.