static void GetRangeValueOfQuery(Args _args)
{
Query query = new Query();
QueryRun queryRun;
QueryBuildDataSource qbd;
Bill_Table vendTable;
QueryBuildRange range;
int ct, i;
;
qbd = query.addDataSource(tablenum(Bill_Table));
queryRun = new QueryRun(query);
queryRun.prompt(); // To Prompt the dialog
ct = queryRun.query().dataSourceTable(tablenum(Bill_Table)).rangeCount();
for (i=1 ; i<=ct; i++)
{
range = queryRun.query().dataSourceTable(tablenum(Bill_Table)).range(i);
info(strfmt(“Range Field – %1, Value – %2”,range.AOTname(),range.value()));
}
range = qbd.addRange(fieldnum(Bill_Table,ItemName));
while (queryRun.next())
{
vendTable = queryRun.get(tablenum(Bill_Table));
info(strfmt(“Item – %1, Name – %2”,vendTable.ItemName, vendTable.CustName));
}
}
Hi,
I used the same in Ax 2012 but it is not working, I couldn’t get the count.
// Vasanth Arivali
LikeLike
hi vasanth,
can you share your code?
//John
LikeLike
Hi John,
I used the same code what you posted. Instead of Bill_Table, I have used GeneralJournalAccountEntry table.
// Vasanth Arivali
LikeLike
Hi vasanth
for me it is working fine in Ax 2009 but not in Ax 2012.
* if u r doing in Ax2009 then you have to add range in Query Prompt Window
* if u r doing in Ax 2012 you have to add range in Query Prompt Window and the you have to change the code like this for count
cnt = SysQuery::countTotal(queryRun);
* after addin the above code im getting count, but Range 1 not found error coming. so if u find any solution please let me know.
//John
LikeLike
Hi vasant,
i got the solution for Ax 2012.Insted of using queryrange.value(i) we have to use query.queryFilter(i);. Just try this and let me the know.
Code:
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));
}
}
thanks for asking the question.
//John
LikeLike
Pingback: Get the ranges and values from Query ( Dynamic/AOT ) using X++ in Ax 2012 | Learn Dynamic Ax with Johnkrish
Pingback: get filter value from grid | hello Dynamics AX
Pingback: 获取网格控件的筛选值 / get filter value from grid – ww12345678 的部落格 | AX Helper