Posting SalesOrder Confirmation with SalesFormLetter Class in Ax

Description: -
The Book of orders in Microsoft Dynamics AX is done through the class "sales form letter" or one of its more concrete (derived) classes.

Each reservation type (eg confirmation, delivery note, invoice) is represented by a class that is derived from the base class "sales form letter" (see illustration).

To reserve an order by code, an object of class "sales form letter" can be created.

salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);

This is done as common practice in Microsoft Dynamics AX, on the "construct" method of the class. must be specified as parameters to this method the desired type of booking (eg confirmation, delivery note, invoice).

The "construct" a method generates the appropriate transaction type, object and returns that (in this case, a "SalesFormLetter_Confirm" object created).

The actual book is called the method "update". Since this method can all be submitted for the booking necessary data as parameters, is a single assignment of such a mandate which is to be posted not necessary. 

For example:
--- Book without print

static void PostingConfimation(Args _args)
{
    SalesFormLetter     salesFormLetter;
    SalesTable          salesTable;
    SalesId             salesId;
    PrintJobSettings    printJobSettings;
    
    ;
    
    //Angabe des Auftrags, welcher gebucht werden soll.
    salesId = "SalesOrderId";
    salesTable = SalesTable::find(salesId);
    // Bestimmen des Buchungstyps durch Angabe des DocumentStatus
    salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);
    //Buchen des Auftrags (aber nicht Drucken).
    salesFormLetter.update(salesTable,SystemDateGet(),SalesUpdate::All,AccountOrder::None,NoYes::No,NoYes::No);
} 

This example is good to see that necessary for the posting of a job essentially only two steps.
On the method "construct" the company produce a type PCX object.
By calling the method "update" to book the order.
Of course, even more extensive or more specialized booking scenarios with the class are ready to buy "sales form letter." For example it is possible to print the same booking with these documents (once, several times and in different formats), open to the mask for the booking (for the user to influence within the company) or the booking is not directly run, but this provide for batch processing.
Thus, it is not too complex, just one more example of booking and simultaneously print the appropriate documents. 

--- Book with print 

static void PostingConfimation(Args _args)
{
    SalesFormLetter     salesFormLetter;
    SalesTable          salesTable;
    SalesId             salesId;
    PrintJobSettings    printJobSettings;
    ;
    salesId = "SalesOrderId";
    salesTable = SalesTable::find(salesId);
    salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);
    salesFormLetter.update(salesTable,SystemDateGet(),SalesUpdate::All,AccountOrder::None,NoYes::No,NoYes::Yes);
    printJobSettings = new PrintJobSettings(salesFormLetter.printerSettingsFormletter(PrintSetupOriginalCopy::Original));
    printJobSettings.setTarget(PrintMedium::File);
    printJobSettings.format(PrintFormat::PDF);
    printJobSettings.fileName(@"C:Test_Order.pdf");
    salesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());
    salesFormLetter.printJournal();
}

Related Posts

Previous
Next Post »

Thanks for comments.....