Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

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

SalesPackingSlip to PDF Duplicate

(0) ShareShare
ReportReport
Posted on by 563

Dear Experts,

I use Microsoft Dynamic AX 2012, creating a function with X to generate SalesPackingSlip as PDF but always get duplicate file

pastedimage1594348598431v3.png

Here is my code

public static void printPackingSlipToPDF(CustPackingSlipJour _custPackingSlipJour)
{
    SalesPackingSlipJournalPrint salesPackingSlipJournalPrint;
    Set set = new Set(Types::Record);
    SRSPrintDestinationSettings srsPrintDestinationSettings;
    
    FilePath filePath = @"E:\Bintang\pdf\"   _custPackingSlipJour.PackingSlipId   ".pdf";
    // Add record
    set.add(_custPackingSlipJour);

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

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

    // Print
    salesPackingSlipJournalPrint.printJournal(set);
}

Please kindly give me some correction and advice

Thank you before

Best Regards,

Bintang

  • Suggested answer
    udaY-ch Profile Picture
    udaY-ch 4,624 on at
    RE: SalesPackingSlip to PDF Duplicate

    Hi

    By default,  controller class is the standard way which is used to print the report based on the print medium (file, email, screen)

    Print management lets you control print settings for selected reports. Print settings include the number of copies, the printer destination, and the multi language text that can be included on the report.For instance, let's say you always wanted to send the report to vendor as email when user posts PO confirmation.  Here come's the print destination settings where email settings are set for the purchase confirmation report.

    docs.microsoft.com/.../set-up-print-management-for-a-module

    This can also be overriden to specific vendor or customer

    docs.microsoft.com/.../set-up-print-management-for-a-customer-or-vendor

    Uday

  • Bintang Profile Picture
    Bintang 563 on at
    RE: SalesPackingSlip to PDF Duplicate

    Hi Uday,

    Thank for your response

    What's the different between using SRSPrintDestinationSettings and Controller?

    Regards,

    Bintang

  • Suggested answer
    udaY-ch Profile Picture
    udaY-ch 4,624 on at
    RE: SalesPackingSlip to PDF Duplicate

    Hi,

    That's standard way of printing and saving the report when used through print destination settings. Even the same happens when I tried saving as file using Use print destination settings which keeps the original file as it is and check the below piece of code for reference.

    pastedimage1594355377129v1.png

    If packing slip export is what you wanted then please check the post below and you  can use report controller class to export report as PDF.

    community.dynamics.com/.../547552

    Uday

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

Announcing Our 2025 Season 1 Super Users!

A new season of Super Users has arrived, and we are so grateful for the daily…

Vahid Ghafarpour – Community Spotlight

We are excited to recognize Vahid Ghafarpour as our February 2025 Community…

Tip: Become a User Group leader!

Join the ranks of valued community UG leaders

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 292,492 Super User 2025 Season 1

#2
Martin Dráb Profile Picture

Martin Dráb 231,305 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans