Monday, 20 April 2020

Flight features in D365FO

Flights are used to disable new features which will change the user experience. With this concept we are able to explicitly enable new features and not by default.

Scenario:

With the PU 34 update, MS introduced fights to Journal printing. So the new code is called as flight is disabled by default.

As the flight is not enabled, it will go to else part in the code shown in pic.

To enable flight to it, write the below script:

SQL:

INSERT INTO SYSFLIGHTING (FLIGHTNAME, ENABLED, FLIGHTSERVICEID) VALUES ('LedgerJournal_UseOldLegerJournalDPReport', 1, 12719367)

or

X++ :

if (!SysTestFlightingManager::isFlightEnabled("LedgerJournal_UseOldLegerJournalDPReport"))
        {
            SysTestFlightingManager::setFlightEnabled("LedgerJournal_UseOldLegerJournalDPReport", DefaultNoYes::Yes);
            Info("Flight enabled");
        }


Reference:

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());