Posting journals from X++ code on the user's behalf is an inseparable supplement to journal creation explained in the Creating new general journals recipe. Normally, this operation is done right after the journal is created or later when some user action is triggered.
In this recipe, we will explore how to post general journals from X++ code. The journal we are going to process is the one we created in the Creating new general journals recipe.
Open AOT and create a new class called JournalPost with the following code (replace
000152_010
with your journal number):class JournalPost { } public static void main(Args _args) { LedgerJournalCheckPost jourPost; LedgerJournalTable jourTable; ; jourTable = LedgerJournalTable::find('000152_010'); jourPost = LedgerJournalCheckPost::newLedgerJournalTable( jourTable, NoYes::Yes); jourPost.run(); }
Run the class and notice the Infolog confirming that...