Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

SRSPrintDestinationSettings producing duplicate PDF file

Posted on by 125

Hi Everyone,

I am trying to save proforma sales invoices to PDF using SRSPrintDestinationSettings. This is working fine. However, the issue is that it also save a duplicate pdf file into a new folder under the same folder. Can someone please point how can i solve this issue ?

My code is :

static void AK_ProformaInvoicesPrint(Args _args)

{

    SalesFormLetter salesFormLetter =  SalesFormLetter::construct(DocumentStatus::Invoice);

    SalesParmLine   parmLine;

    SalesLine       salesline;

    SalesTable      salesTable;

    SRSPrintDestinationSettings     printerSettings;

    printerSettings = new SRSPrintDestinationSettings();

 

    salesTable = salesTable::find("SOA00036974");

 

    salesFormLetter.salesTable(salesTAble);

    salesFormLetter.transDate (systemDateGet());

    salesFormLetter.specQty (SalesUpdate::All);

    //If you want proforma you can enable the code

    salesFormLetter.proforma (true);

    salesFormLetter.printFormLetter (true);

    salesFormLetter.usePrintManagement(false);

        //link the printer settings to the controller

 

    //print to pdf and always overwrite if the file exists

    printerSettings.printMediumType(SRSPrintMediumType::File);

    printerSettings.fileFormat(SRSReportFileFormat::PDF);

    printerSettings.overwriteFile(true);

    printerSettings.fileName("\\\\10.20.10.7\\AXTestData\\AX\\Prints\\"+salesTable.SalesId+".pdf");

    printerSettings.printerComment();

    salesFormLetter.updatePrinterSettingsFormLetter(printerSettings.pack());

    salesFormLetter.initParmSalesTable(salesTAble);

 

    salesFormLetter.initParameters(salesFormLetter.salesParmUpdate(),Printout::Current);

    salesFormLetter.initLinesQuery();

    while select forUpdate parmLine where parmLine.ParmId == salesFormLetter.parmId()

    {

        salesLine = salesline::findInventTransId(parmLine.InventTransId);

        if (salesline.ShippingDateRequested > today())

        {

            ttsBegin;

            parmLine.delete();

            ttsCommit;

        }

    }

    salesFormLetter.run();

 

}

Best Regards,

*This post is locked for comments

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: SRSPrintDestinationSettings producing duplicate PDF file

    I suggest the Duplicate Files Deleter is the best option.

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans