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.
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.
Populated with data, and then the update itself is performed.
Below example will shows how to Post the Invoice from sales order, similar logic's 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
SalesFormLetter_Invoice invoice;
SalesTable salesTable;
;
// 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
invoice.update(salesTable,
SystemDateGet(),
SalesUpdate::All,
AccountOrder::None,
false,
true); // Set to true to print the invoice
}
{
// Define a classvariable according to the
// type of posting being performed
SalesFormLetter_Invoice invoice;
SalesTable salesTable;
;
// 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
invoice.update(salesTable,
SystemDateGet(),
SalesUpdate::All,
AccountOrder::None,
false,
true); // Set to true to print the invoice
}
The next screenshot shows the class hierarchy of FormLetter with all its sub classes: we can easily customize the above logic to post different status updates against sales orders
and purchase orders
and purchase orders
Sales (Confirmation, Picking list, Packing slip, Invoice )
Purch (Purchase order,Receipt list, Packing slip, Invoice)
Purch (Purchase order,Receipt list, Packing slip, Invoice)