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
mario
(Mario David)
July 28, 2019, 12:28pm
#2
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:
/*
* Copyright (c) 2008-2019 Haulmont.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.haulmont.addon.emailtemplates.core;
import com.haulmont.addon.emailtemplates.builder.EmailTemplateBuilder;
import com.haulmont.addon.emailtemplates.dto.ReportWithParams;
This file has been truncated. show original
I hope this helps.
Bye
Mario