Thursday, January 09, 2014

AX2012 R2 CU7 have Dimension Import Export Framework bundled and it's has fixed some bugs and added new default entities over the previous version. Bugs still exists though -_-'.
This time I came across an error saying Financial Dimension value <value> does not exists when I try to import data using the Opening Balance entity.How to reproduce:
- Use Dynamics AX Demo database (USMF).
- Create a Text source data format. Set the DimensionAttribute as BusinessUnit-CostCenter-Department
- Create a processing group. Add Opening Balance Entity in it. Then create an entity in the group that use the above source data format.
- Generate a source file.
- In the source file, entered a transaction where money is debited from a bank account (110110) to the petty cash account (110180). (Please forgive me if this transaction doesn't make real world sense. =])

Here's what I put for the LedgerDimension and the OffsetLedgerDimension field:
LedgerDimension (110110-001--)
OffsetLedgerDimension (110180-001-007-022)

Import to staging database is fine, but when you try to push to Target there is an error: Financial dimension value 007 does not exist.

What happened?
During the process, AX get the list of dimension attribute from system settings. In this case, for the 110xxx account, the active Dimension Attributes are BusinessUnit and Department only.
So it looks like [MainAccount,BusinessUnit,Department]. AX also look at the Dimension Values we imported, for our OffsetLedgerDimesnion, it's [110180-001-007-022].

So we have 3 items in the Dimension Attributes list and 4 items in the Dimension values list. In this particular example, the Dimension Values does not exists error was generated because of this. When I look at the code, it seems to expect a matching set of Dimension Attributes and Dimension Values. How to fix it?Now the fun part. The fix mention below tackle particularly the case of Opening Balance Entity. However, it can be used with other entities easily with minimal effort if you encounter this error dealing with other entities.
Go to \Classes\DMFDimensionHelper\generateDynamicDimension method, add a 3rd parameter DMFDataSourceProperties.

Finally, pass in the DMFDataSourceProperties from the DMFLedgerBalanceEntityClass. In the
GenerateLedgerDimension and GenerateLedgerOffsetDimension method, edit the call to DMFDimensionHelper::generateDynamicDimension() method by adding the dmfDataSourcePropertiesGlobal at the end.
For example, in GenerateLedgerDimension method: