Skip to main content

Notifications

Announcements

No record found.

Finance | Project Operations, Human Resources, ...
Suggested answer

How to run report from runnable class ?

(0) ShareShare
ReportReport
Posted on by 312
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
  • Martin Dráb Profile Picture
    Martin Dráb 230,476 Most Valuable Professional on at
    How to run report from runnable class ?
    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.
  • Teevo Profile Picture
    Teevo 312 on at
    How to run report from runnable class ?
    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.
  • Suggested answer
    Layan Jwei Profile Picture
    Layan Jwei 7,278 Super User 2024 Season 2 on at
    How to run report from runnable class ?
    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
    Teevo 312 on at
    How to run report from runnable class ?
    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
    Martin Dráb Profile Picture
    Martin Dráb 230,476 Most Valuable Professional on at
    How to run report from runnable class ?
    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();

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

Congratulations 2024 Spotlight Honorees

Kudos to all of our 2024 community stars! 🎉

Meet the Top 10 leaders for December

Congratulations to our December super stars! 🥳

Start Your Super User Journey

Join the ranks of our community heros! 🦹

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,784 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,476 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Product updates

Dynamics 365 release plans