Tuesday 4 September 2012

Function DimensionValidation::validateByTree has been incorrectly called.

While Creating General Journal using X++ , we faced this error:
Function DimensionValidation::validateByTree has been incorrectly called.

First let us go through , why we are getting this :

This error is coming because we are passing the account and offset account in wrong manner to LedgerJournalTrans . The field OffsetLedgerDimension and LedgerDimension are of type :
DimensionDynamicAccount , so before passigng the Account to these field , we need to convert the account to correct type . How to do it:

For non ledger account(Bank, customer ..............) , we do have the API :
DimensionStorage::getDynamicAccount(A/cNo ,LedgerJournalACType::Bank);

we need to pass this AS :

LedgerJournalTrans .LedgerDimension  = DimensionStorage::getDynamicAccount(Hedging_table.AccountID,LedgerJournalACType::Bank);

There you go.......

But what to do with Ledger Account , you still can not pass these account directly as well .

Well there is one more API which can help us :

LedgerJournalTrans .getLedgerDimensionForLedgerType(Ledger A/c,jourTrans.Company);
LedgerJournalTrans .LedgerDimension  = 
LedgerJournalTrans .getLedgerDimensionForLedgerType(Ledger A/c,jourTrans.Company);



Please put your comment ,if you find it helpful or looking for some more info......


Thanks,