This blog contains posts from the AX support team highlighting interesting features or issues within AX.
In AX 2012 there are a couple of different ways you can programmatically create combinations of dimensions. These combinations are saved as records in the DimensionAttributeValueCombination table. The RecId from the DimensionAttributeValueCombination table is what is saved in the LedgerDimension field on the LedgerJournalTrans table.
The first and best way to create dimension combinations is to use the class and method DimensionServiceProvider\buildDimensionStorageForLedgerAccount. The buildDimensionStorageForLedgerAccount method takes aLedgerAccountContract class. In the LedgerAccountContract class there are two parm methods, parmMainAccount and parmValues. The parmMainAccount method takes the MainAccount like ‘10060’ and the parmValues method takes a list of the other dimension values you want to set. More specifically the parmValues method takes a list of classes. The classes are of type DimensionAttributeValueContract. On the DimensionAttributeValueContract class you set twomethods, parmName and parmValue. For example, ‘Department’ for the name and ‘10’ for the value. Build up a list of DimensionAttributeValueContract classes for each dimension you want to specify and then pass the list to the parmValues method on the LedgerAccountContract class. Once you have the LedgerAccountContract built up send it to the DimensionServiceProvider\buildDimensionStorageForLedgerAccount.
Optionally you can use a utility method in AX in AxdDimensionUtil\getLedgerAccountId. This one is not as nice as buildDimensionStorageForLedgerAccount because it takes a container instead of a class (with known types). Here’s an example of the method in AX:
container myContainer = ["110180-USAA", “110180”, 1, "Country", "USAA"]; //The third argument, 1, indicates the number of dimensions you are going to include, this does not include the main account.
Here is another example constructing the contents of thecontainer with the dimensions included in the demo data
// Construct input
// Display value strFmt('%1-%2-%3-%4', ‘10060’, '10’, ‘2020’, ‘M010’),
// Main account
// Segment count
// 2nd segment of 1st hierarchy
// 3rd segment of 1st hierarchy
// 4th segment of 1st hierarchy
Other Microsoft Sites
I'm a Customer
I'm a Partner
Use the official Twitter tags:
#MSDYNCOMM | #CONV13