Passing input parameters to report from a screen controller

Hi, is there a way to pass input parameters to a report from screen controller. For instance, I have few parameters like single object and a list of objects and I’d like to pass them to report function and get a report based on data I’ve passed.
Is this possible?
Or maybe there is some workaround for that.

We’d really appreciate any help here.
Thanks in advance.

Hi,

you can use standard actions: com.haulmont.reports.gui.actions.TablePrintFormAction and com.haulmont.reports.gui.actions.EditorPrintFormAction

or if you need something more special you can modify behavior of the underlying cuba_ReportGuiManager bean (com.haulmont.reports.gui.ReportGuiManager) to accomplish your goals.

Regards,
Ilia.

1 Like

@ilya.rodionov

Thanks, for the quick reply, and I saw that bean ReportGuiManager has functionality that I can use for that and honestly I’ve been thinking about this approach.
But as you probably know that this bean is used as a dependency in AbstractPrintFormAction that is parent class for TablePrintFormAction.
And before method I need is being called, a lot of things happening.
Which means that I’ll have to copypaste a pretty lot of code. Basically, I’ll have to duplicate almost all these two classes.
Is this only way to achieve my goals?

Regards,
Paul.

I don’t really think there is another way to do this since this is the only entry point available on screens as far as I know. What kind of parameters are you going to pass? AbstractPrintFormAction focused on passing entity/entity collection but you can have you own Action for you task. Or you can replace the bean if it’s easier to got the parameters in its runReport method.

Ilia

This is a bit of code from a current project:

Map<String, Object> reportParams = new HashMap<>();
reportParams.put("DETAILS", invoicesTable.getSingleSelected().getCofcDetails());
reportParams.put("INVOICE", invoicesTable.getSingleSelected());

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

Report report = dataService.load(lContext);
reportGuiManager.printReport(report, reportParams, "DEFAULT", "testReposrt"));

You can pass report parameters into your template through the HashMap using the names of the parameters as the keys. In my code, I have two parameters “INVOICE” and “DETAILS” that contain the entity and list of entities to use in the report.

2 Likes

Hi llia,
I have to using
(you can use standard actions: com.haulmont.reports.gui.actions.TablePrintFormAction and com.haulmont.reports.gui.actions.EditorPrintFormAction

or if you need something more special you can modify behavior of the underlying cuba_ReportGuiManager bean (com.haulmont.reports.gui.ReportGuiManager) to accomplish your goals.)
standard action form and Repor _Gui _Manager is applicable for single entity report generator r list of entity report generation…
llia give me example screen shot of the complated reporting using template.