Create and add datasource and range in X++ code:
// 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);
}
Use query object in query run functionality:
// 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));
}
}
thanks
ReplyDeleteThanks for nice post how if we want to add range using user input from two inter text box (I am new in AX)
ReplyDeleteRegards
Great post, very helpful for beginners like me. Please provide me with more links to similar stuff..Thanks
ReplyDeleteThis comment has been removed by the author.
ReplyDeleteThis comment has been removed by the author.
Deletehow to add filter/addRange in query run functionality
ReplyDelete