Posting Invoice from Sales order/ Purchase order.
June 29, 2010 6 Comments
One of the most commonly used classes in AX are the FormLetter classes. The
FormLetter classes define how to post different status updates against sales orders
and purchase orders.
The normal flow when a posting is being performed is that the parm tables are
Populated with data, and then the update itself is performed.
Below example will shows how to Post the Invoice from sales order, similar logics can be used to post the Invoice from Purchase order.
static void postSalesInvoice(Args _args)
// Define a classvariable according to the
// type of posting being performed
// Select the salesTable to update
salesTable = SalesTable::find(“SO-101297”);
// Create a new object of the SalesFormLetter_Invoice
// by using the construct-method in SalesFormLetter
invoice = SalesFormLetter::construct(DocumentStatus::Invoice);
// Post the invoice
true); // Set to true to print the invoice
The next screenshot shows the class hierarchy of FormLetter with all its subclasses: we can easily custamize the above logic to post different status updates against sales orders
and purchase orders
Sales (Confirmation, Picking list, Packing slip, Invoice )
Purch (Purchase order,Receipt list, Packing slip, Invoice)