AX 2012分组依据公用表

问题描述 投票:1回答:1

如何按具有特定字段的公用表分组?

我在(dt.fieldname2Id('BatchNo'))上遇到语法错误

这是我的代码:

Common          common;
SysDictTable    dt;

dt        =    SysDictTable::newName('Table1');
common    =    dt.makeRecord();

while select count(RecId) from common
    group by common.(dt.fieldname2Id('BatchNo'))  //syntax Error here
    where common.(dt.fieldname2Id('flag'))==1
{
    info(int642str(Common.Recid));
}
axapta x++ dynamics-ax-2012 dynamics-ax-2012-r3
1个回答
4
投票

您可以改用Query

Common                  common;
SysDictTable            dt;
Query                   query = new Query();
QueryBuildDataSource    qbds; 
QueryRun                queryRun;

dt     = SysDictTable::newName('SalesTable');
common = dt.makeRecord();

qbds = query.addDataSource(common.TableId);
qbds.addGroupByField(dt.fieldname2Id('CustAccount'));

queryRun = new QueryRun(query);

while (queryRun.next())
{
    ...
}
© www.soinside.com 2019 - 2024. All rights reserved.