Full width home advertisement

Post Page Advertisement [Top]

Guys below is the code to implement paging in AX 2012 
Important point worth special mention is that you have to have a proper sort by in place without which it won’t work.
And apart from doing the enablePositionPaging there is one more possibility namely enableValueBasedPaging but you need to make a value based decision which type of paging you want to do and why?

 static void ImplementPaging(Args _args)
 {
     Query query = new Query();
     QueryBuildDataSource qbds;
     QueryRun qr;
     Tableid tableId;
     Common common;
     tableid = tablename2id('VendTable');
     //Add a datasource to a query 
    qbds = query.addDataSource(tableid); 
    //Order by accountnum
    qbds.addOrderByField(fieldname2id(tableid,'AccountNum'));
    //Instantiate a Queryrun class 
   qr = new QueryRun(Query);
   qr.literals(true);
   // Enable position paging for the queryrun object
    qr.enablePositionPaging(true);
   //Add a range by providing the parameters as starting record number and number of records              qr.addPageRange(1,10);
 while (qr.next())
 {
         common = qr.getNo(1);
         info(strFmt("% 1 :",common.(Fieldname2id(tableid, 'AccountNum'))));
 }
 }

 There are other possibility as well to do paging with the help of Meta Services that have found its place in AX 2012 , but that is outside the current purview but if somebody is interested he can approach me in person.

Tidak ada komentar:

Posting Komentar

Bottom Ad [Post Page]