AX 2012 | D365: Post Sales Invoice using X++
static void postSalesInvoice(Args _args) { SalesFormLetter salesFormLetter; SalesTable salesTable; SalesId salesId = ‘005063’; System.Exception error; str strError; CustInvoiceJour custInvoiceJour; ; ttsBegin; try { salesTable = SalesTable::find(salesId); if (salesTable && salesTable.SalesStatus == SalesStatus::Delivered) { salesFormLetter = SalesFormLetter::construct(DocumentStatus::Invoice); salesFormLetter.update(salesTable, systemDateGet(), SalesUpdate::All, AccountOrder::None, NoYes::No, NoYes::No, NoYes::No, NoYes::Yes); if (salesFormLetter.parmJournalRecord().TableId == tableNum(CustInvoiceJour)) { custInvoiceJour = salesFormLetter.parmJournalRecord(); info(strFmt(‘Sales Order #:%1…