How can I export multiple PO invoices to PDF? - using dynamic file names (and paths) based on PO number of invoices being crated?

1. The user selects multiple PO's from the "All Purchase Orders" screen.

2. User then clicks the confirmation button (on the purchase tab) which then opens a dialog allowing them to provide printing parameters.

3. If the user selects, "To File" and "PDF" as file type, they want each PO invoice to be given the file name of the PO number (and perhaps customer down the road).
The code below does work, in that, it will create the multiple PO invoices, but they are not being dynamically named only the first found PO Id is being used for all file names....but AX will find that the file is a duplicate when writing the PDF to disk and will then append an iterative number to the file name (to prevent dupes). I found this is being done within the class: SrSReportRunPrinter.toFile() method.
Can anyone provide a way to enumerate, then pack/collect the dynamic filenames, (maybe using insCon or something) in order to provide the multiple dynamic file names being created at run-time? thanks!
The below code is within the "purchFormLetter" class....
 printSettings = new SRSPrintDestinationSettings(purchFormLetter.printerSettingsFormletter());
            if (record is PurchTable)
            {
                purchTable  = record as PurchTable;
                purchTbl = args.record();
            }
            while (purchTbl)
            {
            if((printSettings.printMediumType() == SRSPrintMediumType::File) &&
                (printSettings.fileFormat() == SRSReportFileFormat::PDF))
            {

                printSettings.printMediumType(SRSPrintMediumType::Screen);
                printSettings.fileName(purchTbl.PurchId);
            }
                next purchTbl;
            }
                purchFormLetter.updatePrinterSettingsFormLetter(printSettings.pack(),PrintSetupOriginalCopy::Original);
                purchFormLetter.updatePrinterSettingsFormLetter(printSettings.pack(),PrintSetupOriginalCopy::Copy);
Related
Recommended