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

Notifications

Announcements

Community site session details

Community site session details

Session Id :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to run report from runnable class ?

(0) ShareShare
ReportReport
Posted on by 397
Hello guys,
 
May I know how to run SSRS report from runnable class ?
Also, should we create Menu item output first then call this object instead ? 
 
Thanks
I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    238,281 Most Valuable Professional on at
    A report should have a menu item that you'll add to the main menu or to forms and that you'll use in security configuration. But calling it from code is possible too, if you have logic that doesn't belong to the controller class (e.g. you want to print to a file in an automated process, rather than letting users to select a print destination.
     
    Here is an example:
    SrsReportRunController          controller = new SrsReportRunController();
    SysUserLicenseCountRDPContract  rdpContract = new SysUserLicenseCountRDPContract();
    SRSPrintDestinationSettings     settings;
     
    // Define report and report design to use
    controller.parmReportName(ssrsReportStr(SysUserLicenseCountReport, Report));
    // Use execution mode appropriate to your situation
    controller.parmExecutionMode(SysOperationExecutionMode::Synchronous);
    // Suppress report dialog
    controller.parmShowDialog(false);
     
    // Explicitly provide all required parameters
    rdpContract.parmReportStateDate(systemDateGet());
    controller.parmReportContract().parmRdpContract(rdpContract);
     
    // Change print settings as needed
    settings = controller.parmReportContract().parmPrintSettings();
    settings.printMediumType(SRSPrintMediumType::File);
    settings.fileFormat(SRSReportFileFormat::Excel);
    settings.fileName('UserLicenseCount.xlsx');
     
    // Execute the report
    controller.startOperation();
  • Teevo Profile Picture
    397 on at
    Hi Martin,
     
    Thanks so much. That is so cool. I will try that. 
    Btw, if I only want to test run it, that's why I'm saying run from runnable class (job), I just googling and try based on my "basic" understanding and turns out, my report can run, but is there something I need to take note if I run it like this ?
    internal final class Test_Run
    {
    
        public static void main(Args _args)
        {
            MenuFunction    menuFunction;
                     
            menuFunction = new MenuFunction(menuitemoutputstr(MyReport), MenuItemType::Output);
            menuFunction.run(_args);
        }
    }
    
    Thanks again.
  • Suggested answer
    Layan Jwei Profile Picture
    8,158 Super User 2025 Season 2 on at
    Hi Teevo,
     
    You could somehow simply copy the code inside the main method of the controller class related to your report, then paste it in the runnable class.
    So it would be sth like this:
     
    YourController controller = new YourController();
    controller.parmReportName(ssrsReportStr(YourReportName, YourReportDesignName));
    controller.StartOperation();
     
    Thanks,
    Layan Jweihan
    ​​​​​​​Please mark this answer as "Verified" if it solved your issue. In order to help others who will face a similar issue in the future
  • Teevo Profile Picture
    397 on at
    Hi Layan,
     
    Thanks. But my intention actually simply to run test my report. And at this point, I didn't have or create any controller class. This report also not yet plan to put in the menu.
    It's actually just me learning report development :)
     
    Anyway I can see in the later stage, I might need this controller class, then I can run that also from my runnable class.
     
    Thanks.
  • Martin Dráb Profile Picture
    238,281 Most Valuable Professional on at
    If you just want to run your report, simply create a menu item for this purpose; you can delete it later if you won't need it in the real solution. But it's much less work than writing a runnable class with all the code.
     
    There always is a controller class, you just don't have to create your own if the standard logic works for you. In that case, SrsReportRunController class is used. You can see that the code I gave you also uses SrsReportRunController and not a custom controller written specifically for one particular report.

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

News and Announcements

Season of Giving Solutions is Here!

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 > Finance | Project Operations, Human Resources, AX, GP, SL

#1
Abhilash Warrier Profile Picture

Abhilash Warrier 843 Super User 2025 Season 2

#2
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 428 Super User 2025 Season 2

#3
Martin Dráb Profile Picture

Martin Dráb 357 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans