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 :
Finance | Project Operations, Human Resources, ...
Suggested Answer

How to run report from runnable class ?

(0) ShareShare
ReportReport
Posted on by 403
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,769 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
    403 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,165 Super User 2026 Season 1 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
    403 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,769 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

Quick Links

Introducing the 2026 Season 1 community Super Users

Congratulations to our 2026 Super Stars!

Congratulations to our 2025 Community Spotlights

Thanks to all of our 2025 Community Spotlight stars!

Leaderboard > Finance | Project Operations, Human Resources, AX, GP, SL

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 509 Super User 2026 Season 1

#2
Giorgio Bonacorsi Profile Picture

Giorgio Bonacorsi 375

#3
Adis Profile Picture

Adis 268 Super User 2026 Season 1

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans