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

Notifications

Announcements

No record found.

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,284 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,284 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,284 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,284 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

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#1
Priya_K Profile Picture

Priya_K 4

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans