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
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))]
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.
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,253 Super User 2024 Season 2
Martin Dráb 230,188 Most Valuable Professional
nmaenpaa 101,156