web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Suggested Answer

WebApi retrieveMultipleRecords - how to process GUID

(0) ShareShare
ReportReport
Posted on by 37
I'm calling Xrm.WebApi.online.retrieveMultipleRecords() with one of the fields in the select list being the record identifier. When I run the query in a browser I can see the GUID as expected:

"new_applicationid":"63790951-dec7-e411-97a1-d4ae52b8c92e"

I'm accessing the values for processing inside a for loop with (for example):
var term = results.entities[i]["new_term"];
When I do this with the identifier however rather than the GUID my variable is undefined. Do I have to process GUID values in a different way?
I have the same question (0)
  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Hello,

    Can you please provide the code you use and what exactly doesn't work?

  • CMG11 Profile Picture
    37 on at

    Sorry, I thought I had included enough detail. My WebApi call is this:

    Xrm.WebApi.online.retrieveMultipleRecords("new_application", "?$select=new_term,new_nbr,new_decision,new_reply,new_applicationid&$filter=statecode eq 0 and new_term eq '"+term+"'").then(

                           function success(results) {

                               for (var i = 0; i < results.entities.length; i++) {

                                   var url = "<a href='"+ clientUrl + results.entities[i]["new_applicationid"] +"' target='new'>" + results.entities[i]["new_nbr"] + "</a>";

                           var term = results.entities[i]["new_term"];

                           var course = results.entities[i]["new_name"];

                           var decision = results.entities[i]["new_decision@OData.Community.Display.V1.FormattedValue"];

                           var reply = results.entities[i]["new_reply@OData.Community.Display.V1.FormattedValue"];

                               }

                            },

                           function(error) {

                               Xrm.Utility.alertDialog(error.message);

                           }

                       );

    All my attributes are being saved to the variables with the exception of the GUID, new_applicationid: results.entities[i]["new_applicationid"] is undefined when checked. The GUID does appear correctly in the results when the query is run on a browser. So my question is do I need to handle a GUID passed from the results differently to how I handle a string or an option set?

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Now it's more or less clear. That's weird that new_applicationid is not there.

    My recommendation - try to debug your code to see what's going wrong. I composed a video that describes steps you can use to troubleshoot your JS - www.youtube.com/watch

  • CMG11 Profile Picture
    37 on at

    It doesn't throw any errors, when I view the variable after it runs it just says undefined but it doesn't interrupt execution in any way

  • a33ik Profile Picture
    84,331 Most Valuable Professional on at

    Check the video, put the breakpoint, check records returned and I'm pretty sure you'll get an answer.

  • Suggested answer
    Bipin D365 Profile Picture
    28,983 Moderator on at

    Hi,

    I would recommend to check results collection in chrome developer tool. HIT F12 on your browser and search your JS.

    Also, Can you try generating web api code using Rest Builder tool and see if code generated from that tool and your code are same.

    If found helpful, Please mark my answer verified.

  • CMG11 Profile Picture
    37 on at

    One of those very strange ones. All day yesterday every check of the value in the console.log came back as undefined. Today it's suddenly returning the correct values. Thank you for your time, I'd been using the developer tools to check console but didn't know I could add breakpoints so that will be useful going forwards.

  • Suggested answer
    a33ik Profile Picture
    84,331 Most Valuable Professional on at

    I'm glad you was able to resolve your issue. If any replies helped you take a minute and click "Yes" under the question "Did this answer your question" at the top of reply (replies) that helped you.

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
Tom_Gioielli Profile Picture

Tom_Gioielli 81 Super User 2025 Season 2

#2
Gerardo Rentería García Profile Picture

Gerardo Rentería Ga... 49 Most Valuable Professional

#3
#ManoVerse Profile Picture

#ManoVerse 40

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans