Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Unanswered

Function DimensionValidationRequest::newForLedgerDimensionType has been incorrectly called.

(0) ShareShare
ReportReport
Posted on by 516

Hi guys,

I'm creating payment journal using X , initially it was fine and had been ran successfully (able to post via x ) for few days, but just recently (today) I got this error which I'm not sure what happened : 

Function DimensionValidationRequest::newForLedgerDimensionType has been incorrectly called.

My code is as simple as like this : 

ledgerjournalname = LedgerJournalName::find(CustParameters::find().TEST_CustomerPaymentJourName);

ledgerjournaltable.JournalName = ledgerjournalname.JournalName;
ledgerjournalTable.initFromLedgerJournalName();

ledgerjournalTable.JournalNum = JournalTableData::newTable(ledgerjournalTable).nextJournalId();
ledgerJournalTable.Name       = strFmt("Payment on %1.", today());
ledgerjournalTable.insert();

While select....
{
    ttsbegin;
    NumberSeq                       numberSeqTransVoucher;
                        
    CustTable                       custTable = CustTable::find(receiptGroupTmpSelect.CustAccount);
    RetailTransactionTable          retailTable = RetailTransactionTable::findReceiptId(MyTable.receiptId);
    container                       txtReceiptIds;
    ledgerjournalTrans.JournalNum       = ledgerjournalTable.JournalNum;
    numberSeqTransVoucher               = NumberSeq::newGetVoucherFromId((ledgerjournalname.NumberSequenceTable));
    ledgerJournalTrans.TransDate        = MyTable.TransDate;
    LedgerJournalTrans.Company          = curExt();
    ledgerjournalTrans.Voucher          = numberSeqTransVoucher.voucher();
    ledgerjournalTrans.TransactionType  = LedgerTransType::Payment;
    ledgerjournalTrans.AccountType      = LedgerJournalACType::Cust;
    ledgerJournalTrans.LedgerDimension  = LedgerDynamicAccountHelper::getDynamicAccountFromAccountNumber(custTable.AccountNum,LedgerJournalACType::Cust);
    ledgerJournalTrans.DefaultDimension = retailTable.DefaultDimension;
    ledgerjournalTrans.parmAccount(custTable.AccountNum,ledgerjournalTrans.AccountType);
    ledgerJournalTrans.postingProfile   =  CustParameters::find().PostingProfile;

    ledgerJournalTrans.Txt              = MyTable.Txt;
    LedgerJournalTrans.PaymReference    = MyTable.PaymReference;
            
    ledgerjournalTrans.CurrencyCode     = retailTable.currency;
                                
    txtReceiptIds                            = [receiptInvPayMatchMasterGroupbyReceipt.ReceiptId];
    ledgerJournalTrans.ExchRate             =  CurrencyExchangeHelper::newExchangeDate(Ledger::current(),
                                                              receiptGroupTmpSelect.transDate).                                                                                                               calculateCurrencyToCurrency(ledgerjournalTrans.CurrencyCode,
                                                 Ledger::accountingCurrencyByLedger(Ledger::current()), MyTable.paymentAmount,true);
                                
    ledgerJournalTrans.PaymMode                 =  MyTable.CustPaymMode;
    ledgerJournalTrans.modifiedField(fieldNum(LedgerJournalTrans,PaymMode));
    ledgerJournalTrans.OffsetAccountType        =  MyTable.OffsetAccountType;
    ledgerjournaltrans.OffsetCompany            =  curExt();
    ledgerjournalTrans.OffsetLedgerDimension    =  CustPaymModeTable::find(ledgerJournalTrans.PaymMode).PaymentLedgerDimension;
    ledgerJournalTrans.modifiedField(fieldNum(LedgerJournalTrans,OffsetLedgerDimension));
                                
    ledgerJournalTrans.insert();

}


LedgerjournalCheckPost      LedgerjournalCheckPost;
LedgerjournalCheckPost      =   LedgerjournalCheckPost::newLedgerJournalTable(LedgerjournalTable,NoYes::Yes);
LedgerjournalCheckPost.run();

Someone mentioned about Account structure changed, but there is no changes and currently is Active.

Thanks

  • Ken Manhattan Profile Picture
    Ken Manhattan 516 on at
    RE: Function DimensionValidationRequest::newForLedgerDimensionType has been incorrectly called.

    I've remove the line for assigning PaymentLedgerDimension ->

    ledgerjournalTrans.OffsetLedgerDimension    =  CustPaymModeTable::find(ledgerJournalTrans.PaymMode).PaymentLedgerDimension;

    and the error is gone. It looks like doesn't need to assign "manually", then the standard code will assign it, based on the account type.

    But there is another thing though, about the Offset default dimension. I am wondering since I didn't "manually" assign the OffsetLedgerDimension it self, how am I going to assign Offset Default Dimension ? And as this is based on account type, how to correctly get the default dimension of it (for example if bank, then the bank default dimension, if account then account default dimension)

    Thanks,

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,234 Super User 2025 Season 1 on at
    RE: Function DimensionValidationRequest::newForLedgerDimensionType has been incorrectly called.

    Hi Ken,

    Have you enabled the option to debug in other models? You can enable more models via the options settings in the Dynamics 365 add-in.

  • Ken Manhattan Profile Picture
    Ken Manhattan 516 on at
    RE: Function DimensionValidationRequest::newForLedgerDimensionType has been incorrectly called.

    Now I'm thinking whether there is something not right on the way I make the payment journal ?

    Is there something I missed ? or something not in order ?

    I look at some blogs, but since everything and everyone has its own way of doing it, I'm more confuse then ever.

    Anyone can help me on this ?

    Thanks,

  • Ken Manhattan Profile Picture
    Ken Manhattan 516 on at
    RE: Function DimensionValidationRequest::newForLedgerDimensionType has been incorrectly called.

    What really confuse me is the mentioned function, not even call when I debug. I have put the break point in DimensionValidationRequest void newForLedgerDimensionType, but not reach there.

    pastedimage1681892853852v1.png

    it is not to this and I can't find where in LedgerJournalCheckPost call this then error.

    What I can find so far is in LedgerJournalCheckPost - RunInternal, it will goes to CatchError, ->

    pastedimage1681893010317v2.png

    Right after running this statement : [postingSuccess, intercompanyPostingSuccess] = this.postJournal();

    But the postJournal actually return True for both, means no problem ?

    pastedimage1681894074808v4.png

    Thanks

  • Ken Manhattan Profile Picture
    Ken Manhattan 516 on at
    RE: Function DimensionValidationRequest::newForLedgerDimensionType has been incorrectly called.

    Yes, actually I did, however this posting process  (LedgerjournalCheckPost) contain so many function and many classes call each other, which I get lost so many time when doing it.

    So the reason I'm post in here probably someone have face this before and can point me to the right place.

    Anyway I will keep debugging.

    Thanks

  • André Arnaud de Calavon Profile Picture
    André Arnaud de Cal... 292,234 Super User 2025 Season 1 on at
    RE: Function DimensionValidationRequest::newForLedgerDimensionType has been incorrectly called.

    Hi Ken,

    As the function is not used in your custom coding, I would suggest using the debugger to find the culprit. It might be data related.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Congratulations to the January Top 10 leaders!

Check out the January community rock stars...

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,234 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 230,994 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans