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

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

Printing reports from code in AX2012 X++

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Community Member Profile Picture
    on at

    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();

  • Verified answer
    Martin Dráb Profile Picture
    239,124 Most Valuable Professional on at

    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()));
  • Suggested answer
    Rustem Galiamov Profile Picture
    8,072 on at

    Hi Gnanaprakash!

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

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

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Meet the Microsoft Dynamics 365 Contact Center Champions

We are thrilled to have these Champions in our Community!

Congratulations to the March Top 10 Community Leaders

These are the community rock stars!

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
CP04-islander Profile Picture

CP04-islander 16

#2
GiacomoRovai Profile Picture

GiacomoRovai 4

#3
Douglas Noel Profile Picture

Douglas Noel 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans