Runtime query in AX 2012
// Code using X++ to build the query
Query query;
QueryRun queryRun;
QueryBuildDataSource qbds;
SalesTable salesTable;
;
query = new Query();
// Add a datasource to the query
qbds = query.addDataSource(tableNum(SalesTable));
// Add a range to the newly added datasource.
qbds.addRange(fieldNum(SalesTable,SalesId)).value("00403_1036..00412_1036");
queryRun = new QueryRun(query);
while(queryRun.next())
{
salesTable = queryRun.get(tableNum(SalesTable));
info(SalesTable.SalesId + ", " + SalesTable.CustAccount);
}
// Code using a query string
static void Job14(Args _args)
{
Query query;
QueryRun queryRun;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
EcoResDistinctProductVariant ecoResDistinctProductVariant;
query = new query(queryStr(EcoResProductVariantsPerCompany));
queryRun = new QueryRun(query);
while (queryRun.next())
{
ecoResDistinctProductVariant = queryRun.get(tableNum(ecoResDistinctProductVariant));
info (strFmt("%1 - %2", EcoResDistinctProductVariant.SearchName, EcoResDistinctProductVariant.ProductMaster));
}
}
http://kashperuk.blogspot.com/2011/10/tutorial-ax2012-new-way-of-accessing.html
// Code using X++ to build the query
Query query;
QueryRun queryRun;
QueryBuildDataSource qbds;
SalesTable salesTable;
;
query = new Query();
// Add a datasource to the query
qbds = query.addDataSource(tableNum(SalesTable));
// Add a range to the newly added datasource.
qbds.addRange(fieldNum(SalesTable,SalesId)).value("00403_1036..00412_1036");
queryRun = new QueryRun(query);
while(queryRun.next())
{
salesTable = queryRun.get(tableNum(SalesTable));
info(SalesTable.SalesId + ", " + SalesTable.CustAccount);
}
// Code using a query string
static void Job14(Args _args)
{
Query query;
QueryRun queryRun;
QueryBuildDataSource qbds;
QueryBuildRange qbr;
EcoResDistinctProductVariant ecoResDistinctProductVariant;
query = new query(queryStr(EcoResProductVariantsPerCompany));
queryRun = new QueryRun(query);
while (queryRun.next())
{
ecoResDistinctProductVariant = queryRun.get(tableNum(ecoResDistinctProductVariant));
info (strFmt("%1 - %2", EcoResDistinctProductVariant.SearchName, EcoResDistinctProductVariant.ProductMaster));
}
}
http://kashperuk.blogspot.com/2011/10/tutorial-ax2012-new-way-of-accessing.html
No comments:
Post a Comment