Hi
I have created YARG report using excel template using the wizard.
The objective is to print Invoice from invoice entry Editor screen when it is saved.
I have generated the attached report template as downloaded from my application.
Report for entity Retail Invoice.zip (16.2 KB)
What happens is that, when I am in the retailInvoice.editor screen and click the button it shows message “there are no reports for this screen”.
Here is my code:
public void print() {
List<Report> reports = reportGuiManager.getAvailableReports(getId(), userSession.getUser(), getItem().getMetaClass());
if (reports.size() > 1) {
openLookup("report$Report.run", items -> {
if (!items.isEmpty()) {
Report report = (Report) items.iterator().next();
runReport(report);
}
}, WindowManager.OpenType.DIALOG, ParamsMap.of(ReportRun.REPORTS_PARAMETER, reports));
} else if (reports.size() == 1) {
Report report = reports.get(0);
runReport(report);
} else {
showNotification(messages.getMessage(ReportGuiManager.class, "report.notFoundReports"),
NotificationType.HUMANIZED);
}
}
private void runReport(Report report) {
ReportInputParameter parameter = report.getInputParameters().stream()
.filter(inputParam -> reportGuiManager.parameterMatchesMetaClass(inputParam, getItem().getMetaClass()))
.findFirst()
.orElseThrow(() -> new ReportingException("No suitable report parameter found"));
ReportOutputDocument reportResult =
reportGuiManager.getReportResult(report, ParamsMap.of(parameter.getAlias(), getItem()), null);
showOptionDialog("Print options", "What do you want to do with the report?",
MessageType.CONFIRMATION, new Action[]{
new AbstractAction("show", Action.Status.PRIMARY) {
{
setCaption("Show");
}
@Override
public void actionPerform(Component component) {
exportDisplay.show(new ByteArrayDataProvider(reportResult.getContent()),
reportResult.getDocumentName());
}
},
new AbstractAction("download") {
{
setCaption("Download");
}
@Override
public void actionPerform(Component component) {
exportDisplay.show(new ByteArrayDataProvider(reportResult.getContent()),
reportResult.getDocumentName(), ExportFormat.OCTET_STREAM);
}
},
new DialogAction(DialogAction.Type.CANCEL)
});
}
Based on the message, it seems the reportGuiManage is unable tp file the report for the entity.
Thanks for your help CUBA team.