This post is machine-translated. The original post in german language can be found here.
These post applies to following version:
Dynamics AX 2012
Dynamics AX 2012
Thanks for de DEMO. When I save packingslip to a file, it generates two files. the desired one and same file into temp folder. Do you know why? |
|
|
|
|
|
|
The following job demonstrates, how you can print an existing Sales packing slip through code. The example sends the report to screen.
static void printSalesPackingSlipThroughCode(Args _args) { SalesPackingSlipJournalPrint salesPackingSlipJournalPrint; Set set = new Set(Types::Record); SRSPrintDestinationSettings srsPrintDestinationSettings; // Add record set.add(CustPackingSlipJour::findRecId(5637161120)); // Set printer settings srsPrintDestinationSettings = new SRSPrintDestinationSettings(); srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen); // Initalize salesPackingSlipJournalPrint = SalesPackingSlipJournalPrint::construct(); salesPackingSlipJournalPrint.parmPrintFormletter(NoYes::Yes); salesPackingSlipJournalPrint.parmUsePrintManagement(false); salesPackingSlipJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack()); // Print salesPackingSlipJournalPrint.printJournal(set); }Changing the parameter of the instance of SRSPrintDestinationSettings allows you to send the sales packing slip to printer, file or mail. The next example creates a PDF-file.
static void printSalesPackingSlipThroughCode(Args _args) { SalesPackingSlipJournalPrint salesPackingSlipJournalPrint; Set set = new Set(Types::Record); SRSPrintDestinationSettings srsPrintDestinationSettings; // Add record set.add(CustPackingSlipJour::findRecId(5637161120)); // Set printer settings srsPrintDestinationSettings = new SRSPrintDestinationSettings(); srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::PDF); srsPrintDestinationSettings.fileName(@'c: emppackingslip.pdf'); srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::File); srsPrintDestinationSettings.numberOfCopies(1); srsPrintDestinationSettings.overwriteFile(true); // Initalize salesPackingSlipJournalPrint = SalesPackingSlipJournalPrint::construct(); salesPackingSlipJournalPrint.parmPrintFormletter(NoYes::Yes); salesPackingSlipJournalPrint.parmUsePrintManagement(false); salesPackingSlipJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack()); // Print salesPackingSlipJournalPrint.printJournal(set); }If you want to print multiple sales confirmations at once, you have to add the corresponding CustPackingSlipJour-records to the set called "set:
... // Add record set.add(CustPackingSlipJour::findRecId(5637155842)); set.add(CustPackingSlipJour::findRecId(5637145354)); ...To additionally save the sales packing slip to print archive, you can add the following line:
... srsPrintDestinationSettings.parmPrintToArchive(true); ...