Thursday, 2 April 2020

X++ code to find the available printers to print from AX (Print Sales picking list report at designated printer)



printJobSettings  printJobSettings;
sysPrintOptions  sysPrintOptions;
map                     printerMap;
mapIterator         mapIterator;
    ;
printJobSettings = SysPrintOptions::newPrintJobSettingsOnServer();
sysPrintOptions = new sysPrintOptions();
sysPrintOptions.setPrintJobSettings(printJobSettings);
sysPrintOptions.buildPrinterMap();
printerMap        = sysPrintOptions.getPrinterMap();
mapIterator       = new mapIterator(printerMap);
mapIterator.begin();
while (mapIterator.more())
{
      info(mapIterator.value());
      mapIterator.next();
 }

Scenario:
In order to print a sales picking list to the desired destination(printer):

1. Class responsible to print picking list is "SalesPickingListJournalPrint".
2. You need to override the printSettings and pass it to FormLetter. Write the below code before call the doPrint method (SalesPickingListJournalPrint.doPrint())


private void ChangePrintSettings(Name_printerName)

{
    SRSPrintDestinationSettings printSettings = new SRSPrintDestinationSettings();

    printSettings.printMediumType(SRSPrintMediumType::Printer);
    printSettings.printerName(_printerName);

    //this.parmUsePrintManagement(false);
    this.parmPrinterSettingsFormLetter(printSettings.pack());

No comments:

Post a Comment