Tuesday 13 May 2014

Queries in AX 2012

EXPANDED QUERY IN THE AOT

Query query;
QueryRun queryRun;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
SalesTable SalesTable;
;
query = new Query();
//this line attaches a table to the qbds data source object
qbds = query.addDataSource(TableNum (SalesTable));

//this line attaches a range to the 'SalesTable' 
//data source, the range is the CustAccount
qbr = qbds.addRange(FieldNum (SalesTable,CustAccount));

// The range is set to '2001'
qbr.value ('2001');

// The query will sort by sales id
qbds.addSortField (FieldNum(SalesTable,SalesId));

// The queryRun object is instantiated using the query
queryRun = new QueryRun(query);

// The queryRun object loops through all records returned
while (queryRun.next())

{
// The current record is assigned to the salesTable variable
SalesTable = queryRun.get(tableNum(SalesTable));
print SalesTable.SalesId;
}

No comments:

Post a Comment

SQL/SSRS Interview questions I thought of blogging some SQL/SSRS interview questions.

Below are some. I will add more, when I complete the compilation 1. What is OLTP(Online Transaction Processing)? OLTP stands ...