Axaptapedia is now maintained by AgileCadence For more information please click here.
Programming against dimensions
The usual method of programming against a specific dimension in Ax is as follows:
<xpp> salesTable.Dimension[SysDimension::Center + 1] = 'The cost centre'; </xpp>
However, this code is not technically correct. It relies on the enum value of the dimension matching the array dimension (plus 1), which is not guaranteed. If a developer follows Microsoft's best practice guide and gives a non-sequential enum value to a new financial dimension (e.g. 100) then the code will not work.
It is better to use the following pattern when assigning to/reading from specific dimensions in X++ code. This maps the dimension to the correct array index, irrespective of the enum value.
<xpp> salesTable.Dimension[Dimensions::code2ArrayIdx(SysDimension::Center)] = 'The cost centre'; </xpp>