Sending scheduled report with parameters with emailtemplate addon

I want to send a report on regular interval with email template addon. My report has single parameter tenant (for multitenancy) witch has to be set in code. As per documentation on email template add on it may be possible by .setAttachmentParameters(reportsWithParams).

I have made report and email template and defined schedule witch call a bean to send email,

But, I am not able to understand - how can I set parameter for report in code.

regards

umesh

hi,

i’m not sure if you are talking about this addon: GitHub - mariodavid/cuba-component-scheduled-reports: CUBA component that let's you schedule reports and execute them periodically or if you are working directly with the email addon.

In case you use the scheduled-reports addon, you have to to override the provideParameters method like in the extension as done here: cuba-example-using-scheduled-reports/MonthlySalesReportScheduledReportExtension.java at master · mariodavid/cuba-example-using-scheduled-reports · GitHub

    @Override
    public Map<String, Object> provideParameters(ScheduledReport scheduledReport) {

        Map<String, Object> params = new HashMap<>();
        params.put("from", toDate(salesReportPeriod().atDay(1)));
        params.put("to", toDate(salesReportPeriod().atEndOfMonth()));
        params.put("month", salesReportPeriod().toString());
        return params;
    }

In case, you use the email template addon directly, there is an example out, which uses the email template API programmatically, to create an email template: GitHub - cuba-platform/emailtemplate-addon-demo: Demo application for email templates CUBA component

Here you can see the different options available to pass parameter into the API:

I hope this helps.

Bye
Mario

Thanks @mario,

I will check.