0
votes

The code below is what I am using for my invoices to be Posted

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"

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.

What could be wrong when that error pops up?

Edit1: As I've used breakpoint, I found out that in LedgerJournalCheckPost.validate() the ledgerJournalTable.JournalNum is empty "".

1
Hi. Sorry but that's not the error, only a typo in my question. Updated my question. - m1gs
Could you show the code that you use to create the LedgerJournalTable record? Also could you debug if field JournalNum has a value at some point and if so, when this value gets lost before the call to validate()? - FH-Inway

1 Answers

0
votes

Found out that the ledgerJournalCheckPost.run() already has/calls the validate() method inside it, so there's no need to call the validate() method. However, I still don't know how to solve if you're going to use the validate() method through x++o code.