Action buttons for report export

Hello everyone,

I need to have two action buttons in one of the Entity browse screen, which should invoke two different reports ( which should export data in different formats). Now when I click one of the buttons, the window with the available reports is shown.

Could you please let me know how to connect each button with the correct report, so when the button is clicked the right report is invoked (so if the button for .doc is clicked, the report for .doc format is started and if the button for pdf is clicked, the report for pdf is started), without the need to select the report?

Thank you in advance.

Hello Dimitar!

If you have two different reports, you can define programmatically which one should be executed. Just invoke methods on a button click, passing the report ID or, for example, its SYSTEM CODE (as well as any other parameters):

private ReportGuiManager reportGuiManager = AppBeans.get(ReportGuiManager.class);

    public void runReport() {
        Map<String, Object> reportParams = new HashMap<>();
        reportParams.put("entities", libraryDepartmentTable.getSelected());

        LoadContext<Report> lContext = new LoadContext<>(Report.class);
        lContext.setQueryString("select r from report$Report r where r.code = 'departments' ");

        Report report = dataService.load(lContext);
        reportGuiManager.printReport(report, reportParams, "DEFAULT", "Report for selected departments");
    }

Moreover, in the upcoming 6.7 release of the platform, we are going to let the user choose the output type of a report (say .doc or .pdf) in production just before running the report, thus to avoid building 2 distinct but redundant reports with identical templates in development.

These topics may also be useful for you:

https://www.cuba-platform.com/discuss/t/how-to-pass-parameterfrom-a-particular-screen-to-report-script

This helped me. Thank you very much.