Value Based Paging

Limitations of Value-Based Paging
In Dynamics Ax 5, Value based paging will not work on queries with outer joins.

Value Based Paging in X++
 sourceCursor: record to start (and include) reading from. isForward: when true, the queryRun reads from the beginning of the query (as if paging was not applied), up to and not including the bookmark cursor. 

static void ValuePagingDemoJob {  QueryRun queryRun, queryNewRun; Common cursor; Common tbl; Query query; int i,p; int cursorIndex = 3;

query = new Query(queryStr(TestQuery)); queryRun = new QueryRun(query);

//Set Start Cursor for(p = 1; p <= cursorIndex; p++) {      queryRun.next; for(i = 1; i <= query.dataSourceCount; i++) {         tbl = queryRun.getNo(i); info( strfmt("No: %1 | %2",i,tbl.recId )); }       info(""); }   info("Setting Cursor"); cursor = queryRun.getNo(1); //-- // new Query Run queryNewRun = new QueryRun(query);

queryNewRun.enableValueBasedPaging(true); queryNewRun.applyValueBasedPaging(cursor);

if( queryNewRun.isValueBasedPagingEnabled ) {       info("Value Paging Enabled"); }

while(queryNewRun.next) {       for(i = 1; i <= query.dataSourceCount; i++) {         tbl = queryNewRun.getNo(i); info( strfmt("No: %1 | %2",i,tbl.recId )); }       info(""); }

}

Sample infolog output: No: 1 | 5637144578 No: 2 | 5637144577 No: 3 | 5637144580 No: 1 | 5637144578 No: 2 | 5637144580 No: 3 | 5637144579 No: 1 | 5637144578 No: 2 | 5637144581 No: 3 | 5637144583 Setting Cursor Value Paging Enabled No: 1 | 5637144578 No: 2 | 5637144581 No: 3 | 5637144583 No: 1 | 5637144582 No: 2 | 5637144576 No: 3 | 5637144583 No: 1 | 5637144581 No: 2 | 5637144578 No: 3 | 5637144576