Thursday, December 18, 2008

Packing Slip posting

The Book of orders in Microsoft Dynamics AX is done about the class "Sales form letter or a specified their (secondary) classes. Each (confirmation, delivery, billing) is through a separate class, which from the base class "Sales form letter" is derived (see illustration). 
. To a job as a program code book, an object of class "Sales form letter" to be created. 
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);
 
. This happens as general in Microsoft Dynamics AX usual, the "construct" method of the class. As parameter of this method has the desired type of booking (eg confirmation, delivery, billing party). The "construct" method creates a Buchungsart the corresponding object and gives them back (in this case is a "SalesFormLetter_Confirm" object). 
The actual reservation is about the method "update" called.. Since this method for posting all the necessary data as a parameter can be passed, is a single assignment of the contract, for example, which should be posted, not necessary. 
Hierzu ein Beispiel: Here is an example: 
// --- --- Book without expression
static void PostingConfimation(Args _args) 
{
SalesFormLetter salesFormLetter;
SalesTable salesTable; 
SalesId salesId; 
PrintJobSettings printJobSettings; 
;
// Specify the contract, which should be posted.
salesId = "00423_036" ; 
salesTable = SalesTable::find(salesId); 

// Determine the type indicated by posting the Document Status
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation); 

// Book of the contract (but not printing).
salesFormLetter.update(salesTable, 
SystemDateGet(),
SalesUpdate::All, 
AccountOrder::None, 
NoYes::No,
NoYes::No);
}In this example is good to see that for posting a mandate essentially only two steps are necessary. 
On the method "construct" an opponent Buchungstyp the object. 
By calling the method "update" the order book. 
Of course, even larger reservation or something more specific scenarios with "Class sales form letter" will be shown. So it is possible for example, just off the reservation respective print documents (once, repeatedly and in different formats), the mask for the reservation to open (so the user influence on the reservation can take) or the booking is not directly run, but this for the batch ready to make. 
So it is not too complex, just another example, to print and simultaneous posting of similar documents. 
// --- --- Book with expression
static void PostingConfimation_new(Args _args)
{
SalesFormLetter salesFormLetter;
SalesTable salesTable;
SalesId salesId;
PrintJobSettings printJobSettings;
;
// Specify the contract, which should be posted.
salesId = "00036_036" ;
salesTable = SalesTable::find(salesId);
salesFormLetter = SalesFormLetter::construct(DocumentStatus::Confirmation);
// Book of the contract and print (print medium Setting hr).
salesFormLetter.update(salesTable,
SystemDateGet(),
SalesUpdate::All,
AccountOrder::None,
NoYes::No,
NoYes::Yes);

// 2nd expression.
printJobSettings = new PrintJobSettings(salesFormLetter.printerSettingsFormletter(
PrintSetupOriginalCopy::Original));
// Where we want to print (here) file.
printJobSettings.setTarget(PrintMedium::File);

// In what format should be printed (PDF here).
printJobSettings.format(PrintFormat::PDF);
printJobSettings.fileName( @"C:\Test_Order.pdf" );

// Transfer of printing options to the sales letter form object.
salesFormLetter.updatePrinterSettingsFormLetter(printJobSettings.packPrintJobSettings());

salesFormLetter.printJournal();
}

No comments:

How to identify the user that was used to change an object from AOT in AX2012

Get the object name for which we need to track these (user and date&time) information's. Login to SQL Server Management Studio an...