I know we can run run the report from the screen by setting the action to button as its there in many samplers. But how can we automatically select the template from the report screen?
I may have many templates for one report and I dont want to select the template every time from the parameter as it can be automatically selected based on the selected record need report.
Attached is the screenshot where I have 4 different templates for one report.
It’s just a way to load the required report instance using LoadContext. Actually, for passing the template, you need the printReport() method of ReportGuiManager.
If the “underwriters” is a list of entities “multiselect” should be enabled for customersTable.
To avoid IllegalArgumentException you can check whether the records are selected before launching the report.
@Inject
private Table<Customer> customersTable;
...
public void runReport(Component source) {
if (customersTable.getSelected().isEmpty()){ // if no records are selected in the table
showNotification("please select items");
return;
}
Map<String, Object> reportParams = new HashMap<>();
reportParams.put("underwriters", customersTable.getSelected());
...
reportGuiManager.printReport(report, reportParams, templateCode, null);
}