axaptadynamics-ax-2012x++dynamics-ax-2012-r3

Validation before posting a ledger journal


I need to check if some conditions are met before posting a ledger journal, and if not cancel the posting process.

Should i add a code section in class LedgerJournalCheckPost method: validate() ?

My tests are working, and this method is called both when validating or posting so it solves my case.

But is there another approach to accomplish such a thing?


Solution

  • It depends what you're doing. The validate(...) method at \Classes\LedgerJournalCheckPost\validate(...) is used for validating the journal itself. Such as, has it already been posted? Is there a journal number?

    The checkJournal(...) method at \Classes\LedgerJournalCheckPost\checkJournal (and various methods called from this method) is used for checking the data in the journal.

    You should examine this method to see what logically makes the most sense for you.

    You'd probably log posting errors like this too: ok = ledgerPostingMessageCollection.logCheckFailed(...)

    Just look in that method to follow their pattern.