SalesFormLetter class

SalesFormLetter class is a base class for processing various documents on sales orders. Each kind of document is represented as a descendant of this class. For example it is SalesFormLetter_Invoice for invoice.

Description
The class do the following way (see the method main):
 * creates a instance for the particular document (construct method)
 * constructs records in parameter tables: SalesParmTable, SalesParmLine, SalesParmUpdate with the new unique id (can be accessed via parmID property)
 * displays it contents to user to let some tweaks (via SalesEditLines form - see dialog method)
 * processes particular document

Printing proforma for the sales invoice
static void Test_SalesFormLetter(Args _args) {   SalesFormLetter letter=SalesFormLetter::construct(DocumentStatus::Invoice); SalesTable sale = SalesTable::find('ORDR00000229'); ttsBegin; letter.update(sale, systemDateGet, SalesUpdate::PickingList, AccountOrder::None, true, true); ttsCommit; }

The same with tweaking lines qty
static void Test_SalesFormLetter(Args _args) {   SalesFormLetter letter=SalesFormLetter::construct(DocumentStatus::Invoice); SalesTable sale = SalesTable::find('S00000274'); SalesParmLine parmLine; ttsBegin; letter.salesTable(sale); letter.transDate         (systemDateGet); letter.specQty           (SalesUpdate::PickingList); letter.proforma          (true); letter.printFormLetter   (true); //letter.printCODLabel     (NoYes::No); //letter.printFreightSlip  (NoYes::No); //letter.printShippingLabel (NoYes::No); //letter.printBillOfExchange(NoYes::No);

letter.createParmUpdate;

letter.initParameters(letter.salesParmUpdate,                       PrintOut::Current);  // Printout

info(letter.parmId); letter.giroType(sale.giroType); letter.initLinesQuery; while select forUpdate parmLine where parmLine.ParmId == letter.parmId {       // changed the Qty parmLine.DeliverNow = 3; // the following is stollen from the SalesEditLines form (field modified method) parmLine.setQty(parmLine.salesParmTable.ordering, letter.SalesParmUpdate.creditRemaining); parmLine.setInventDeliverNow; parmLine.setLineAmount;

if (parmLine.closed) {           parmLine.remainAfter = 0; parmLine.setRemainAfterInvent; }

parmLine.calcPackingUnitQty;

parmLine.update; }

letter.run; ttsCommit; }

chooseLines
Constructs SalesParmTable and SalesParmLine tables records for

Links

 * Dynamics AX: Preform a PackingSlip Update through code
 * Microsoft Dynamics AX (DAX): How to post SO's or PO's with X++