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 arguments to controller class from Form on button click

(0) ShareShare
ReportReport
Posted on by

Hello all, in a requirement i have to run my report from form where it takes the selected record on form as parameter to process the report. The report dialog should be invisible. How can i achieve this ? 
I have written DP class, contract class and controller class, created an action menu item and set it as menu item button form. But here i am not setting the data source. I need some code level implementation from where the report gets open on button click 

*This post is locked for comments

I have the same question (0)
  • Martin Dráb Profile Picture
    237,805 Most Valuable Professional on at

    What do you mean by "here i am not setting the data source"?

    Don't you get the record when calling args.record() in main() method of the controller class?

  • Suggested answer
    Mrdude Profile Picture
    285 on at

    Your report controller class should extend the SrsReportRunController class:

    class TestRC extends SrsReportRunController

    {

    }

    The main method of your report controller class should look similar to this:

    public static void main(Args _args)

    {

    TestRC    controller = new TestRC();

    DataTable dataTable;

    dataTable = _args.record() as DataTable;

    controller.parmArgs(_args);

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

    controller.parmShowDialog(false);

    controller.startOperation();

    }

    This called pre process pass parameter

    By this controller.parmShowDialog(false)

    The report dialog will not show

    Regards.

  • Suggested answer
    startax Profile Picture
    1,845 on at

    Hi,

    If you are using menu item (Action menu item of your controller class )to open report  then follow below link. From required a data source from where you are opening report.

    https://www.bhsolutions.com/news/blog/how-to-launch-an-ssrs-report-from-ax-with-pre-loaded-parameters/

    And if you want to open report by button click

    Create output menuitem of your report and write below code in button click

    args    args;   //declare args

    ;  

    args = new Args();
    args.caller(element);
    new MenuFunction(menuitemoutputstr(Myreport), MenuItemType::Output).run(args);

    and pass parameter in contract in dp class.

  • Suggested answer
    startax Profile Picture
    1,845 on at

    community.dynamics.com/.../234364

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