Monday, 25 September 2023

Journal reports print through X++

Many a time we come across situations where we need to print the journal reports through X++ on some triggers. We have the below simple code through which we can achieve this. 

Sales Invoice journal Print:

SalesInvoiceJournalPrint salesInvoiceJournalPrint;

Set set = new Set(Types::Record);

SRSPrintDestinationSettings srsPrintDestinationSettings;

// Add record

set.add(CustInvoiceJour::findRecId(XXXXX));

set.add(CustInvoiceJour::findRecId(XXXXX));


// Set printer settings

srsPrintDestinationSettings = new SRSPrintDestinationSettings();

srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::Screen);


// Initalize

salesInvoiceJournalPrint = SalesInvoiceJournalPrint::construct();

salesInvoiceJournalPrint.parmPrintFormletter(NoYes::Yes);

salesInvoiceJournalPrint.parmUsePrintManagement(false);

salesInvoiceJournalPrint.parmPrinterSettingsFormLetter(srsPrintDestinationSettings.pack());

// Print

salesInvoiceJournalPrint.printJournal(set);


The similar code can be used for other journal prints as well

Sales:

  • SalesConfirmJournalPrint -
  • SalesPickingListJournalPrint
  • SalesPackingSlipJournalPrint
Purchase:
  • PurchPurchOrderJournalPrint
  • PurchReceiptListJournalPrint
  • PurchPackingSlipJournalPrint
  • PurchInvoiceJournalPrint