Mar 10, 2015

How to get the query range values through X++ code

static void testQuery(Args _args)
{
Query q;
QueryRun qr;
QueryBuildRange qbr;
str s;
custTrans custTran;
int cnt, i;
queryFilter queryFilter;
;

q = new Query(queryStr(CustOpenInvoicesListPage)); // This is AOT query

qr = new QueryRun(q);

qr.prompt(); // This prompt's the dialog

cnt = qr.query().dataSourceTable(tablenum(custTrans)).rangeCount();

for (i=1 ; i<=cnt; i++)
{
qbr = qr.query().dataSourceTable(tablenum(custTrans)).range(i);
info(strfmt("Field added in Range %1, Range value %2",qbr.AOTname(),qbr.value()));
}

while(qr.next())
{
custTran = qr.get(tableNum(custTrans));
info(strFmt("%1 ---- %2 ",custTran.AccountNum,custTran.TransType));
}
}

No comments: