D365FO – AX – Looping through table buffer (QueryRun) multiple times

queryRun queryRun;
query query = new query();

CustTable custTable;
query.addDataSource(tablenum(CustTable));

while (queryRun.next())
{
custTable = queryRun.get(tablenum(CustTable));
// do something with the buffer …
}

queryRun.reset()

while (queryRun.next()) // another loop process
{
custTable = queryRun.get(tablenum(CustTable));
// do something other with the buffer …
}

Leave a comment