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)

Passing a parameter to an SSRS report from Controller

(0) ShareShare
ReportReport
Posted on by

Hi folks, I need to run a batch job that passing the customer account to the SSRS report Dynamically...and this will write a PDF file per customer.

So I believe I need to call the controller class something like this:

But not sure how to pass the parameter to the report.  The parameter is not in the contract class.  Can't I just pass the parameter to the report by modifying the query range rather than adding the parameter to the contract class?

Thank you in advance...

SrsReportRunController controller = new SrsReportRunController();
SRSPrintDestinationSettings printSettings;

// set report name
controller.parmReportName(ssrsReportStr(AMKcustsevenDayOpen, Report));

controller.parmArgs().parm('custaccount?');

// get print settings from contract
printSettings = controller.parmReportContract().parmPrintSettings();

// set print medium
printSettings.printMediumType(SRSPrintMediumType::File);
printSettings.fileFormat(SRSReportFileFormat::PDF);
printSettings.overwriteFile(true);
printSettings.fileName(@"C:\Temp\Report.pdf");

// suppress the parameter dialog
controller.parmShowDialog(true);

// start operation
controller.startOperation();

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    Hi brianmaric,

    You need to get data contract and set parameter there, something like

    AMKcustsevenDayOpenContract rdpContract = controller.parmReportContract().parmRdpContract() as AMKcustsevenDayOpenContract ;

    rdpContract .parmCustAccount('blah-blah');

  • brianmaric Profile Picture
    on at

    oh...so you just can't pass the parameter to the report query...

  • Mea_ Profile Picture
    60,286 on at

    It's depends how it's done. Is it query based report ? Do you have data contract ?

  • brianmaric Profile Picture
    on at

    It is a query based report and Ideally I don't want to add a parameter to the contract class...possible?

  • Suggested answer
    Mea_ Profile Picture
    60,286 on at

    It is possible, look at LedgerJournalController.setRange() method and it's usage.

  • brianmaric Profile Picture
    on at

    Thanks!!

    ...but how do you call it?

  • Verified answer
    Mea_ Profile Picture
    60,286 on at

    Example is in LedgerJournalController.main(), however, you don't need to do a straight copy, it's just an example, change it according to your needs.

  • brianmaric Profile Picture
    on at

    Thank You!!

    ...but is there any way to suppress the other required parameters?  I tried running it and got an error message saying date parameters are required.  I guess I could just create another design without the parameters but I wonder if there is a way around it.

    Thanks again!

  • Suggested answer
    Mohamed lotfi Profile Picture
    255 on at

    You can use the next code:-

    SrsReportRunController controller = new SrsReportRunController();

    SRSPrintDestinationSettings printSettings;

    SrsReportDataContract   contract;

    YourReportContractClass rdpContractClass;

    // set report name

    controller.parmReportName(ssrsReportStr(AMKcustsevenDayOpen, Report));

    //------  add this section-------//

    contract = controller.parmReportContract();

    rdpContractClass= contract.parmRdpContract() as YourReportcontractClass ;

    rdpContractClass.parmAccountNum(CustTable.AccountNum);

    //--------------//

    // get print settings from contract

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

    // set print medium

    printSettings.printMediumType(SRSPrintMediumType::File);

    printSettings.fileFormat(SRSReportFileFormat::PDF);

    printSettings.overwriteFile(true);

    printSettings.fileName(@"C:\Temp\Report.pdf");

    // suppress the parameter dialog

    controller.parmShowDialog(true);

    // start operation

    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

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
Basit Profile Picture

Basit 1

#1
GL-01081504-0 Profile Picture

GL-01081504-0 1

#1
Roya Profile Picture

Roya 1

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans