Get the ranges and values from Query ( Dynamic/AOT ) using X++ in Ax 2012

My Previous Post:Get the ranges and values from Query ( Dynamic/AOT ) using X++ in Ax 2009 

https://jkmsdax2012.wordpress.com/2015/05/05/get-the-ranges-and-values-from-query-dynamicaot-using-x-in-ax-2009/

static void Johnkrish_GetRangeValueOfQuery(Args _args)
{
Query query;
QueryRun queryRun;
QueryBuildDataSource qbd;
GeneralJournalAccountEntry vendTable;
QueryBuildRange range;
QueryFilter qf;
GeneralJournalAccountEntry generalJournalAccountEntry;
int cnt, i;
;

query = new query();
qbd = query.addDataSource(tablenum(GeneralJournalAccountEntry));
queryRun = new QueryRun(query);
queryRun.prompt();
query = queryRun.query();
cnt=query.queryFilterCount();

for (i = 1; i <=cnt ; i++)
{
qf = query.queryFilter(i);
info(strFmt(“Range Field – %1: Value – %2”, qf.field(), qf.value()));
}

while (queryRun.next())
{
generalJournalAccountEntry = queryRun.get(tablenum(GeneralJournalAccountEntry));
info(strfmt(“PostingType – %1, LederAccount – %2”,generalJournalAccountEntry.PostingType, generalJournalAccountEntry.LedgerAccount));
}
}

Output:

QueryWindow

Output

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s