Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics CRM (Archived)
Answered

Get all record from view using javascript

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Hi all,

Can any one suggest, how we  get all record from view using java script.
We have view Name and view ID, but don't know how to get data from that view using javascript.

Thanks

*This post is locked for comments

  • Suggested answer
    JeganathanG Profile Picture
    JeganathanG 25 on at
    RE: Get all record from view using javascript

    Hi Arun_996 

    Retrieve data from a view in Dynamics 365 using JavaScript, you can use the Xrm.WebApi.retrieveMultipleRecords method of the Web API. You need to pass the entity name and view ID as parameters

    var entityName = "account";
    var viewId = "00000000-0000-0000-0000-000000000010";
    var fetchXml = ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    ""  
                    "";
    
    Xrm.WebApi.retrieveMultipleRecords(entityName, "?fetchXml="   encodeURIComponent(fetchXml)).then(
        function success(result) {
            console.log(result);
        },
        function (error) {
            console.log(error.message);
        }
    );
    

  • ashlega Profile Picture
    ashlega 34,475 on at
    RE: Get all record from view using javascript

    Hey John, thanks for the link!

  • Verified answer
    Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Get all record from view using javascript

    Thanks ALEX

    We have solved this problem in two steps.

    I have followed the below link

    debajmecrm.com/.../leverage-web-api-to-execute-your-system-views-personal-views-and-custom-fetchxml-in-dynamic-crm-2016

  • Suggested answer
    ashlega Profile Picture
    ashlega 34,475 on at
    RE: Get all record from view using javascript

    Hi John,

     I don't think you can do it in one step - you have to get fetchxml for that view first, and, then, you need to run that fetchxml query.

     To run fetchXml, you can use this approach:

    community.dynamics.com/.../use-fetchxml-to-retrieve-data-from-ms-crm-2016-using-web-api

     And you can use the same approach to retrieve fetchXml for the view:

    - You'll be using either SavedQuery or UserQuery entity (depending on what kind of view it is)

    - Here is an example of how you can do it for UserQuery in C# - you won't need any of the authentication in JavaScript.. just look at what the attributes are, and, then, construct your fetchXml for the UserQuery entity  (SavedQuery should be very similar in that sense)

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! 🥳

Get Started Blogging in the Community

Hosted or syndicated blogging is available! ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,354 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans