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.