web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested answer

Problems creating SalesPackingSlip Report and saving it as a PDF file

(0) ShareShare
ReportReport
Posted on by 9

Hi 

I am trying to create a report using X and saving it as a file but I am having a few problems.

First of all: setting the srsPrintDestinationSettings.fileName does nothing at all. No file is written.

    SalesPackingSlipJournalPrint salesPackingSlipJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;
    str directory;

    // Add record
    set.add(custPackingSlipJour);

    // Set printer settings
    srsPrintDestinationSettings = new SRSPrintDestinationSettings();
    srsPrintDestinationSettings.printMediumType(SRSPrintMediumType::File);
    srsPrintDestinationSettings.fileFormat(SRSReportFileFormat::PDF);
    srsPrintDestinationSettings.overwriteFile(true);
    srsPrintDestinationSettings.fileName(filename);

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

    // Print
    salesPackingSlipJournalPrint.printJournal(set);

This code generates the correct report with data but I am unable to save it to disk.

Then I tried this code:

    SrsReportRunController          ssrsController = new SrsReportRunController();
    SalesPackingSlipContract salesPackingSlipContract = new SalesPackingSlipContract();
    SRSPrintDestinationSettings     printerSettings;
    ReportName              reportName = "NCCSalesPackingSlip.Report";

    ssrsController.parmReportName(reportName); 
    ssrsController.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    ssrsController.parmShowDialog(false);

    salesPackingSlipContract.parmRecordId(custPackingSlipJour.RecId);
    ssrsController.parmReportContract().parmRdpContract(salesPackingSlipContract);

    printerSettings = ssrsController.parmReportContract().parmPrintSettings();
    printerSettings.printMediumType(SRSPrintMediumType::File);
    printerSettings.fileFormat(SRSReportFileFormat::PDF);
    printerSettings.overwriteFile(true);

    printerSettings.fileName(filename);
    ssrsController.runReport();

This code generates the correct report but it is empty! Also no file is written to disk.

Whys is my report empty? What am I doing wrong?

regards

Peter

I have the same question (0)
  • Ludwig Reinhard Profile Picture
    Microsoft Employee on at
    RE: Problems creating SalesPackingSlip Report and saving it as a PDF file

    Hi Peter,

    Why don't you use the Electronic Reporting report?

    It's available out of the box, does not require coding and can do the PDF conversion out of the box.

    Best regards,

    Ludwig

  • PeterForsbom Profile Picture
    9 on at
    RE: Problems creating SalesPackingSlip Report and saving it as a PDF file

    Hi

    This is for an integration with another system so I need to do it via code.

    Best regards

    Peter

  • Suggested answer
    Jie G Profile Picture
    on at
    RE: Problems creating SalesPackingSlip Report and saving it as a PDF file

    Hi Peter,

    I tried this code, and can generate a report file with data under "C:\Users\User##\Downloads\Report.pdf"

     public static void main(Args _args)
        {
            SrsReportRunController controller = new SrsReportRunController();
            SRSPrintDestinationSettings printSettings;
            controller.parmReportName(ssrsReportStr(VendAgingReport, DesignWithNoDetailAndNoTransactionCur));
            // get print settings from contract
            printSettings = controller.parmReportContract().parmPrintSettings();
            // set print medium
            printSettings.printMediumType(SRSPrintMediumType::File);
            printSettings.fileFormat(SRSReportFileFormat::PDF);
            printSettings.overwriteFile(true);
            printSettings.fileName(@"Report.pdf");
            // suppress the parameter dialog
            controller.parmShowDialog(false);
            controller.startOperation();
        }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
CA Neeraj Kumar Profile Picture

CA Neeraj Kumar 2,004

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 857 Super User 2025 Season 2

#3
Sohaib Cheema Profile Picture

Sohaib Cheema 548 User Group Leader

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans