AleksandrRogov / DynamicsWebApi

DynamicsWebApi is a Microsoft Dataverse Web API helper library for JavaScript & TypeScript

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

oDataNextLink examples

pixelpaulaus opened this issue · comments

commented

Hello,
Just wondering if you have any examples of using oDataNextLink returned values to fetch the next lot of records?

@pixelpaulaus there's the 2nd parameter in retrieveMultipleRequest where you pass the oDataNextLink to retrieve the next page.
Here's a page from the Wiki

So it should be something like this:

//set the request parameters
const request = {
    collection: "leads",
    select: ["fullname", "subject"],
    filter: "statecode eq 0",
    maxPageSize: 5,
    count: true
};

//perform a multiple records retrieve operation
dynamicsWebApi.retrieveMultipleRequest(request).then(function (response) {

    const count = response.oDataCount;
    const nextLink = response.oDataNextLink;
    const records = response.value;
    
    return dynamicsWebApi.retrieveMultipleRequest(request, nextLink);
}).then(function(response) {
   //page 2
}).catch(function (error){
    //catch an error
});

Closing this.