Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

"Journal does not exist" LedgerJournalCheckPost Validate method posting invoice journal using x++

Posted on by 270

The code below is my code in posting my invoice journal

ledgerJournalTable = header.ledgerJournalTable();        
if (ledgerJournalTable.RecId > 0)
{
    ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(ledgerJournalTable, NoYes::Yes, NoYes::Yes);
    // Post only if there is succesful validation.
    if (ledgerJournalCheckPost.validate())
    {
        ledgerJournalCheckPost.run();
    }
    else
    {
        info("Error.");
    }
}

but there is always an error that says: "Journal does not exist" when it goes into the ledgerJournalCheckPost.validate(). All the values that I've placed on the fields are correct because when I tried to use the same values manually, it was posted.

As I've used breakpoint, I found out that in LedgerJournalCheckPost.validate() the ledgerJournalTable.JournalNum is empty "", so it goes to the checkFailed that shows that the journal does not exist. Here is the snippet:

if (! ledgerJournalTable.JournalNum)
{
    isValid = checkFailed(strFmt("@SYS21496", ledgerJournalTable.JournalNum));
}

Also, I've checked the method newLedgerJournalTable in my code in posting the invoice (as seen above) and it got all the data I am posting. But the validate() does not, where I really need the validate method.

What could be the problem? The error Journal does not exist is the only thing that prevents me from posting. 

*This post is locked for comments

  • Sheikh Sohail Profile Picture
    Sheikh Sohail 6,125 on at
    RE: "Journal does not exist" LedgerJournalCheckPost Validate method posting invoice journal using x++

    There is delegate which execute after validation of journal, you can subscribe this delegate and get the validation result,

     [SubscribesTo(classStr(LedgerJournalCheckPost), delegateStr(LedgerJournalCheckPost, runInternalPostValidateJournalDelegate))]

  • Miguel Zuniga Profile Picture
    Miguel Zuniga 270 on at
    RE: "Journal does not exist" LedgerJournalCheckPost Validate method posting invoice journal using x++

    Hi Sir Crispin. Yes the run() method has a validate inside of it, a colleague of mine told me that yesterday as he was checking my code.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans