Friday, 13 November 2015

Resolve the ledger dimension in the a different account structure [AX 2012]

Recently I had a look at an error that occurred on a custom journal posting routine. It was somewhat similar the journal allocations by looking at existing transaction to make adjustment. What I didn’t know is the account structure has changed. An error popped up: Account structure X for the combination x-x-x-x-x, is not valid for the ledger X.


When ever using ledger dimensions don’t just stamp the LedgerDimensionRecId. Use this method to resolve the RecId in the current account structure for the current company.

toLedgerDimension = DimensionDefaultingService::serviceCreateLedgerDimension(fromLedgerdimension);

I had to do a quick unit test to prove this. Below is a job that converts.

static void resolveLedgerDimension(Args _args)
//My expected values are
//Dimension display value = ''
//Account structure and dimension From RecId - Brazil - 52565566264
//Account structure and dimension Resolved RecId - Brazil SI - 22565539091
RecId fromLedgerdimension = 52565566264;
RecId toLedgerdimension;
toLedgerdimension = DimensionDefaultingService::serviceCreateLedgerDimension(fromLedgerdimension);
info(strFmt("From RecId %1 to %2", fromLedgerdimension, toLedgerdimension));
info(strFmt("From Display value %1 to %2",
conPeek(AxdDimensionUtil::getLedgerAccountValue(fromLedgerdimension), 1),
conPeek(AxdDimensionUtil::getLedgerAccountValue(toLedgerdimension), 1)));
info(strFmt("From Account structure %1 to %2",

In the AOT I found a dimension combination that existed in 2 account structures that are the same.



1 comment:

Anonymous said...

Great article :) Thanks for sharing Your knowledge on microsoft dynamics ax it is always very helpful and interesting :)