Skip to main content

Notifications

Announcements

No record found.

Customer experience | Sales, Customer Insights,...
Suggested answer

WebApi retrieveMultipleRecords - how to process GUID

Posted on by 35
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?
  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: WebApi retrieveMultipleRecords - how to process GUID

    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.

  • CMG11 Profile Picture
    CMG11 35 on at
    RE: WebApi retrieveMultipleRecords - how to process GUID

    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
    Bipin D365 Profile Picture
    Bipin D365 28,964 Super User 2024 Season 1 on at
    RE: WebApi retrieveMultipleRecords - how to process GUID

    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.

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: WebApi retrieveMultipleRecords - how to process GUID

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

  • CMG11 Profile Picture
    CMG11 35 on at
    RE: WebApi retrieveMultipleRecords - how to process GUID

    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

  • Suggested answer
    a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: WebApi retrieveMultipleRecords - how to process GUID

    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
    CMG11 35 on at
    RE: WebApi retrieveMultipleRecords - how to process GUID

    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?

  • a33ik Profile Picture
    a33ik 84,323 Most Valuable Professional on at
    RE: WebApi retrieveMultipleRecords - how to process GUID

    Hello,

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

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!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,235 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans