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 :
Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Unable to read values from result of retrieve multiple records.

(0) ShareShare
ReportReport
Posted on by 595

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.

I have the same question (0)
  • Suggested answer
    Community Member Profile Picture
    on at
    RE: Unable to read values from result of retrieve multiple records.

    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?

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 > Microsoft Dynamics 365 | Integration, Dataverse, and general topics

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 85 Super User 2025 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 57 Most Valuable Professional

#3
Satyam Prakash Profile Picture

Satyam Prakash 49

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans