Skip to main content

Notifications

Microsoft Dynamics 365 | Integration, Dataverse...
Suggested answer

Unable to read values from result of retrieve multiple records.

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.

  • Suggested answer
    Community Member Profile Picture
    Community Member Microsoft Employee 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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,240 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,149 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans