Monday 4 November 2019

Function DimensionValidationRequest::newForLedgerDimensionType has been incorrectly called inD365 F&O

Usually we see the below error when we create payment/general journals using X++ code.

Function DimensionValidationRequest::newForLedgerDimensionType has been incorrectly called.

The reason for this error is ledger dimension/offset ledger dimension(Main account) format is incorrect and assigned this format to ledgerjournalTrans.LedgerDimension or ledgerjournalTrans.OffsetLedgerDimension.

Below is the way to create and assign ledger dimensions.

//Variables
        DimensionDynamicAccount     offsetLedgerDim;
Array  acctDimAttrArray                     = new Array(Types::String);
            acctDimAttrArray.value(1,"MainAccount");

            Array acctDimArray                          = new Array(Types::String);
            acctDimArray.value(1,'123456');

            DefaultDimensionIntegrationValues DefaultDimensionIntegrationValues   = DimensionResolver::getEntityDisplayValue
                    (acctDimAttrArray, acctDimArray, extendedTypeStr(DimensionDynamicAccount), LedgerJournalACType::Ledger);
            DimensionDynamicAccountResolver DimensionDynamicAccountResolver     = DimensionDynamicAccountResolver::newResolver
                (DefaultDimensionIntegrationValues, LedgerJournalACType::Ledger, curExt());
            ledgerjournalTrans.AccountType = LedgerJournalACType::Ledger;
            ledgerjournalTrans.LedgerDimension = DimensionDynamicAccountResolver.resolve();
            ledgerjournalTrans.OffsetAccountType = LedgerJournalACType::Cust;

            offsetLedgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber
                ('1000005', LedgerJournalACType::Cust);
            ledgerjournalTrans.OffsetLedgerDimension = offsetLedgerDim;


In the same way if have main account with multiple dimensions you can follow the format.

Array  acctDimAttrArray                     = new Array(Types::String);
        acctDimAttrArray.value(1,"MainAccount");
        acctDimAttrArray.value(2,"Brand");
        acctDimAttrArray.value(3,"Channel");

        Array acctDimArray                          = new Array(Types::String);
        acctDimArray.value(1,_dataContract.parmMainAccount());//Main account
        acctDimArray.value(2,_dataContract.parmBrand());//Brand dimension
        acctDimArray.value(3,_dataContract.parmChannel());//Channel dimension

  DefaultDimensionIntegrationValues DefaultDimensionIntegrationValues   = DimensionResolver::getEntityDisplayValue
                    (acctDimAttrArray, acctDimArray, extendedTypeStr(DimensionDynamicAccount), LedgerJournalACType::Ledger);
            DimensionDynamicAccountResolver DimensionDynamicAccountResolver     = DimensionDynamicAccountResolver::newResolver
                (DefaultDimensionIntegrationValues, LedgerJournalACType::Ledger, curExt());
           ledgerjournalTrans.AccountType = LedgerJournalACType::Ledger;
            ledgerjournalTrans.LedgerDimension = DimensionDynamicAccountResolver.resolve();
            ledgerjournalTrans.OffsetAccountType = LedgerJournalACType::Cust;

            offsetLedgerDim = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber
                ('1000005', LedgerJournalACType::Cust);
            ledgerjournalTrans.OffsetLedgerDimension = offsetLedgerDim;

That's it.

@Rahul

1 comment:

  1. Hi, thanks a lot for this post! I found the same issue as you and this post helps me to resolve the issue!

    ReplyDelete

Adding a newline into a string in C# and X++

Below is the sample code we can use for  adding a newline after every occurrence of "@" symbol in the string in C#   using System...