Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Printing reports from code in AX2012 X++

(0) ShareShare
ReportReport
Posted on by Microsoft Employee

Am trying to print customer aging report.

i refer this link : http://dev.goshoom.net/en/2018/10/printing-reports-from-code-in-d365fo/

I am using contract class this one is working fine.

My scenario i need to run specific customer in customer aging report like Dynamic or Query filter.

*This post is locked for comments

  • Suggested answer
    Rustem Galiamov Profile Picture
    Rustem Galiamov 8,072 on at
    RE: Printing reports from code in AX2012 X++

    Hi Gnanaprakash!

    You can create a class with dialog. docs.microsoft.com/.../using-classes-to-create-a-dialog

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 230,476 Most Valuable Professional on at
    RE: Printing reports from code in AX2012 X++

    First of all, let me format and clean up your code, so it's easier to follow. next time, please use </> button in the rich formatting view to paste source code.

    Args                            args;
    SrsReportRunController          controller = new SrsReportRunController();
    CustAgingReportContract         rdpContract = new CustAgingReportContract();
    SRSPrintDestinationSettings     settings;
    
    // Define report and report design to use
    controller.parmReportName(ssrsReportStr(CustAgingReport, DesignWithNoDetailAndNoTransactionCur));
    
    // Use execution mode appropriate to your situation
    controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    
    // Suppress report dialog
    controller.parmShowDialog(false);
    
    //Explicitly provide all required parameters
    rdpContract.parmZeroDate(systemDateGet());
    rdpContract.parmStartDate(mkDate(1, 12, 2017));
    rdpContract.parmDateTransactionDuedate(DateTransactionDuedate::TransactionDate);
    rdpContract.parmAgingBuckets("30-60-90-120");
    rdpContract.parmPrintAgingBucketDescription(NoYesCombo::No);
    rdpContract.parmInterval(0);
    rdpContract.parmPeriod(DayMonth::Day);
    rdpContract.parmDirection(ForwardBackwardPrinting::Forward);
    rdpContract.parmExcludeZeroBalanceCustomer(NoYes::Yes);
    rdpContract.validate();
    
    args = new Args();
    args.record(CustTable::find("C003"));
    controller.parmReportContract().parmRdpContract(rdpContract);
    controller.parmArgs(args);
    
    // Change print settings as needed
    settings = controller.parmReportContract().parmPrintSettings();
    settings.printMediumType(SRSPrintMediumType::File);
    settings.fileFormat(SRSReportFileFormat::PDF);
    settings.fileName(@'C:\Test\AgingReportCustAging.pdf');
    
    // Execute the report
    controller.startOperation();

    By the way, notice how I've replaced str2Date("12/1/2017",213) with simpler mkDate(1, 12, 2017).

    Now, you your question. You should be able to get the report contract by this:

    controller.parmReportContract().parmQueryContracts().lookup(controller.getFirstQueryContractKey()));
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: Printing reports from code in AX2012 X++

    This is my code :

    Args                            args;

       SrsReportRunController          controller = new SrsReportRunController();

       CustAgingReportContract         rdpContract = new CustAgingReportContract();

       SRSPrintDestinationSettings     settings;

       CurrencyCode                    currencyCode = "INR";

       CustTable                       custTable;

       custTable = CustTable::find("C003");

       // Define report and report design to use

       controller.parmReportName(ssrsReportStr(CustAgingReport, DesignWithNoDetailAndNoTransactionCur));

       // Use execution mode appropriate to your situation

       controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);

       // Suppress report dialog

       controller.parmShowDialog(false);

        //Explicitly provide all required parameters

       rdpContract.parmZeroDate(systemDateGet());

       rdpContract.parmStartDate(str2Date("12/1/2017",213));

       rdpContract.parmDateTransactionDuedate(DateTransactionDuedate::TransactionDate);

       rdpContract.parmAgingBuckets("30-60-90-120");

       rdpContract.parmPrintAgingBucketDescription(NoYesCombo::No);

       rdpContract.parmInterval(0);

       rdpContract.parmPeriod(DayMonth::Day);

       rdpContract.parmDirection(ForwardBackwardPrinting::Forward);

       rdpContract.parmExcludeZeroBalanceCustomer(NoYes::Yes);

       rdpContract.validate();

       args = new Args();

       args.record(custTable);

       controller.parmReportContract().parmRdpContract(rdpContract);

       controller.parmArgs(args);

       // Change print settings as needed

       settings = controller.parmReportContract().parmPrintSettings();

       settings.printMediumType(SRSPrintMediumType::File);

       settings.fileFormat(SRSReportFileFormat::PDF);

       settings.fileName(@'C:\Test\AgingReportCustAging.pdf');

       // Execute the report

       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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 230,476 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans