Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)

Retrieve another entity record by using GUID of that record in Javascript

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi,

     I want to get another record data by its id in JavaScript for validation purpose can anyone tell me how to get the record by guid or name . In C# i can get the record but java script i don't know how to get another records data.

Thanks,

Mani

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve another entity record by using GUID of that record in Javascript

    Hi Nithya,

        Thanks , i got the answer basically we've to use plural name but not exact plural name, but like below......

    new_city become new_cities, English correct.

    new_wolf become new_wolfs, English incorrect.

    new_knife become new_knifes, English incorrect.

    new_man become new_mans, English incorrect.

    My custom entity's details:

         Display Name: configuration

         plural name: configurations

        Name: new_configuration

    But in the URL i used "new_configurations" that only worked

    Thanks,

    Mani

  • Suggested answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Retrieve another entity record by using GUID of that record in Javascript

    Hi Manikandan,

    Please open the following URL in your browser.

    yourOrganisationUrl/.../EntityDefinitions eq  'YourEntityLogicalName'

    In the results page, find EntitySetName (Ctrl +F). In this way, you can get the entity set name of the required entity (As an example, for Account entity, the entity set name is accounts).

    Hope this helps.

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve another entity record by using GUID of that record in Javascript

    Thanks Mam, but one question that "entitySetName" means which name of the entity (Display name,plural name,name)

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Retrieve another entity record by using GUID of that record in Javascript

    Its working Alex thanks, but i can get the contact entity record by calling "/api/data/v8.1/contacts("+contactId +")?$select=fullname" but i dont know how to get my custom entity's record. i've tried same with my custom entity but no luck means i dont know which name(Display name,plural name,name) of my custom entity i have to use in url

  • Verified answer
    Nithya Gopinath Profile Picture
    Nithya Gopinath 17,074 on at
    RE: Retrieve another entity record by using GUID of that record in Javascript

    Hi Manikandan,

    You could use the following Javascript code using Web API to retrieve a record using its ID.

    function retrieveRecord(recordId) {
        var clientURL = Xrm.Page.context.getClientUrl();
        var req = new XMLHttpRequest();
        var query = "/api/data/v8.2/entitySetName?$filter= idlogicalname eq " + recordId;
        req.open("GET", encodeURI(clientURL + query), true);
        req.setRequestHeader("Accept", "application/json");
        req.setRequestHeader("Content-Type", "application/json;charset=utf-8");
        req.setRequestHeader("OData-MaxVersion", "4.0");
        req.setRequestHeader("OData-Version", "4.0");
        req.onreadystatechange = function () {
            if (this.readyState == 4) {
                req.onreadystatechange = null;
                if (this.status == 200) {
                    var data = JSON.parse(this.response);                
                }
                else {
                    var error = JSON.parse(this.response).error;
                    alert("Error retrieving Record – " + error.message);
                }
            }
        };
        req.send();
    }

    Hope this helps.

  • Verified answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: Retrieve another entity record by using GUID of that record in Javascript

    Hi,

     is this what you need?

    community.dynamics.com/.../ms-crm-2016-web-api-operations-retrieve-single-or-multiple-records

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,458 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans