This post is machine-translated. The original post in german language can be found here.

Print sales confirmation through code

The following job demonstrates, how you can print an existing Sales confirmation through code. The example sends the report to screen.

static void printSalesConfirmThroughCode(Args _args)
{
    SalesConfirmJournalPrint salesConfirmJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustConfirmJour::findRecId(5637155842));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::Screen);

    // Initalize
    salesConfirmJournalPrint = SalesConfirmJournalPrint::construct();
    salesConfirmJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesConfirmJournalPrint.parmUsePrintManagement(false);
    salesConfirmJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesConfirmJournalPrint.printJournal(set);
}

Changing the parameter of the instance of SRSPrintDestinationSettings allows you to send the sales confirmation to printer, file or mail. The next example creates a PDF-file.

static void printSalesConfirmThroughCode(Args _args)
{
    SalesConfirmJournalPrint salesConfirmJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;

    // Add record
    set.add(CustConfirmJour::findRecId(5637155842));

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::PDF);
    srsPrintDestinationSettings.fileName(@'c:\temp\confirmation.pdf');
    srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::File);
    srsPrintDestinationSettings.numberOfCopies(1);
    srsPrintDestinationSettings.overwriteFile(true);

    // Initalize
    salesConfirmJournalPrint = SalesConfirmJournalPrint::construct();
    salesConfirmJournalPrint.parmPrintFormletter(NoYes::Yes);
    salesConfirmJournalPrint.parmUsePrintManagement(false);
    salesConfirmJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

    // Print
    salesConfirmJournalPrint.printJournal(set);
}

If you want to print multiple sales confirmations at once, you have to add the corresponding CustConfirmJour-records to the set called "set:

    ...   
    // Add record
    set.add(CustConfirmJour::findRecId(5637155842));
    set.add(CustConfirmJour::findRecId(5637145354));
    ...

To save the sales confirmation additionally to print archive, you can add the following line:

    ...   
    srsPrintDestinationSettings.parmPrintToArchive(true);
    ...
These post applies to following version:
Dynamics AX 2012

Add comment
 
 

 

 
 
 
Posts of the actual month
April 2024
MoTuWeThFrSaSu
1234567
891011121314
15161718192021
22232425262728
2930 
 
© 2006-2024 Heinz Schweda | Imprint | Contact | German version | Mobile version
In order to provide you with better service, this site uses cookies. By continuing to browse the site, you are agreeing to our use of cookies.