Dynamic query creation in Ax2012
Sub: Creating run time query in job
static void DynamicQuery(Args _args)
{
// Author : Rajaram
// Title : simple query creation
Query query;
QueryBuildDataSource queryBuildDataSource;
QueryBuildRange queryBuildRang;
QueryRun queryRun;
SalesTable salesTable;
;
query = new Query();// creating query instance
queryBuildDataSource = query.addDataSource(tableNum(salesTable));// adding datasource in the query
queryBuildRang = queryBuildDataSource.addRange(fieldNum(salesTable,CustAccount));// set range
queryBuildRang.value("DE-001");// range value
queryRun = new QueryRun(query);// query run
while(queryRun.next())
{
salesTable = queryRun.get(tableNum(salesTable));// geting records from table using query run
info(strFmt("%1 %2",salesTable.SalesId, salesTable.CustAccount));
}
}
No comments:
Post a Comment