This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
Dynamics AX 2012
|
|
|
|
|
|
|
This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
|
|||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
You can use the SysQuery::addOrderByDimensionAttribute() method to sort a query on a financial dimension.
The following example is intended to illustrate this. In this job, all customers are listed, sorted according to the dimension CostCenter.
static void sortByDimension(Args _args) { Query query; QueryRun queryRun; QueryBuildDataSource qbds; CustTable custTable; DimensionComponent dimensionComponent; DimensionValue dimensionValue; #define.CostCenterDimensionName("CostCenter"); query = new Query(); qbds = query.addDataSource(tableNum(CustTable)); SysQuery::addOrderByDimensionAttribute(query, qbds.name(), fieldId2name(tableNum(CustTable), fieldNum(CustTable, DefaultDimension)), DimensionComponent::DimensionAttribute, SortOrder::Ascending, #CostCenterDimensionName); queryRun = new QueryRun(query); while(queryRun.next()) { custTable = queryRun.get(tableNum(CustTable)); // Get dimension value dimensionValue = (select firstonly DisplayValue from defaultDimensionView where defaultDimensionView.Name == #CostCenterDimensionName && defaultDimensionView.DefaultDimension == custTable.DefaultDimension).DisplayValue; info(strFmt("%1 %2", custTable.AccountNum, dimensionValue)); } }