Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Problem when trying to print Original and copy of SalesInvoice toghether

Posted on by 2,983

I have this job in AX 2012 R3 CU12

private void PrintCopyAndOriginal()
{
        CustInvoiceJour     custInvoiceJourLocal;
        Args                args = new Args();
        ;
        select * from custInvoiceJourLocal
        where custInvoiceJourLocal.InvoiceId == 'INV000123';

        args.record(custInvoiceJourLocal);
        new MenuFunction(menuitemOutputStr(SalesInvoiceCopy), MenuItemType::Output).run(args);
        new MenuFunction(menuitemOutputStr(SalesInvoiceOriginal), MenuItemType::Output).run(args);
}

It seems that this code seriously messes up the report contracts, as parmDocumentTitle is set to "COPY" in both reports. Aditionally, one of the reports shows up without lines.

Please kindly test this code, and propose a Workaround.

*This post is locked for comments

  • Ghetz Profile Picture
    Ghetz 2,983 on at
    RE: Problem when trying to print Original and copy of SalesInvoice toghether

    OK.. here is one more update.

    If I insert a delay in my code, the problem partially goes away. I've noticed that some fields in the report are zero, like totals. There is definately an overlapping issue.

    this.PrintV2('FV453371',PrintCopyOriginal::Copy);
    sleep(5000);
    this.PrintV2('FV453371',PrintCopyOriginal::Original);
    private void PrintV2(str 20 factura,PrintCopyOriginal _PrintCopyOriginal)
    {
        args args = new args();
        CustInvoiceJour     custInvoiceJourLocal;
        SRSPrintDestinationSettings printSettings;
        SalesInvoiceController controller = new SalesInvoiceController();
    
        ;
        select * from custInvoiceJourLocal
            where custInvoiceJourLocal.InvoiceId == factura;
    
        args.record(custInvoiceJourLocal);
        args.parmEnum(_PrintCopyOriginal);
        controller.parmReportName(ssrsReportStr(SalesInvoice, Report));
        controller.parmArgs(args);
    
        // suppress the parameter dialog
        controller.parmShowDialog(false);
    
        // start operation
        controller.startOperation();
    }

  • Ghetz Profile Picture
    Ghetz 2,983 on at
    RE: Problem when trying to print Original and copy of SalesInvoice toghether

    Also tried this, with the same problem:

    this.PrintV2('FV453371',PrintCopyOriginal::Copy);
    this.PrintV2('FV453371',PrintCopyOriginal::Original);
    
    private void PrintV2(str 20 factura,PrintCopyOriginal _PrintCopyOriginal)
    {
        args args = new args();
        CustInvoiceJour     custInvoiceJourLocal;
        SRSPrintDestinationSettings printSettings;
        SalesInvoiceController controller = new SalesInvoiceController();
    
        ;
        select * from custInvoiceJourLocal
            where custInvoiceJourLocal.InvoiceId == factura;
    
        args.record(custInvoiceJourLocal);
        args.parmEnum(_PrintCopyOriginal);
        controller.parmReportName(ssrsReportStr(SalesInvoice, Report));
        controller.parmArgs(args);
    
        // suppress the parameter dialog
        controller.parmShowDialog(false);
    
        // start operation
        controller.startOperation();
    }


  • Ghetz Profile Picture
    Ghetz 2,983 on at
    RE: Problem when trying to print Original and copy of SalesInvoice toghether

    I'm afraid this doesn't help much. This solves the issue with parmDocumentTitle (it seems like), but I'm still getting one empty report.

    Looks like making 2 calls one after another causes some kind of problem. Please try to reproduce in your environment. only the first time it worked. Then I ran again, and the problem started. One of the reports is without lines.

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,253 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,188 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans