Yet another blog for Dynamics 365 for Finance and Operations. This blog primarily targets technical readers. I will be sharing my experience with Dynamics AX using code snippets, errors, and solutions, Tips, and tricks. Any feedback regarding a post or overall site are always welcome.
Some time we need to generate a General Journal through X++ code rather than go to GL module. For eg. WE are creating a journal after completion of some particular condition. Try following code to create a General Journal and than post in in the same code through X++. staticvoid theaxapta_CreateGLJournalPost(Args _args) { AxLedgerJournalTable journalTable; // class AxLedgerJournalTrans journalTrans; // class container acctPattern; container offSetAcctPattern; LedgerJournalTable ledgerJournalTable; // table ledgerJournalCheckPost ledgerJournalCheckPost;// table ; journalTable = new AxLedgerJournalTable(); journalTrans = new AxLedgerJournalTrans(); //Journal Name journalTable.parmJournalName("GenJrn"); journalTable.save(); journalTrans.parmJournalNum(journalTable.ledgerJournalTable().JournalNum); journalTrans.parmTransDate(systemDateGet()); journalTrans.parmCurrencyCode("USD"); journalTrans.parmAmountCurDebit(1200); journalTrans.parmAccountType(LedgerJournalACType::Ledger); acctPattern = ["21345-Disp","211345", 2, "Department","0000114","CostCenter", "0000087"]; journalTrans.parmLedgerDimension(AxdDimensionUtil::getLedgerAccountId(acctPattern)); journalTrans.parmOffsetAccountType(LedgerJournalACType:: Ledger ); offSetAcctPattern = ["40100-Disp","40100", 4, "Department","0000114","CostCenter", "0000087", "CustomPurposeA","Nile", "CustomPurposeB", "Site1"]; journalTrans.parmOffsetLedgerDimension(AxdDimensionUtil::getLedgerAccountId( offSetAcctPattern)); journalTrans.save(); ledgerJournalCheckPost = ledgerJournalCheckPost::newLedgerJournalTable(journalTable.ledgerJournalTable(),NoYes::Yes); ledgerJournalCheckPost.run(); info(strFmt("Journal No. %1.", journalTable.ledgerJournalTable().JournalNum)); }