How can we use email templates in a multitenant environment where I don’t want access to one tenant’s email template by others? I tried to find it in the documentation but didn’t come across any.
EmailTemplates add-on doesn’t support multitenancy out of the box. You may try to extend required entities from the add-on and make them work with multi-tenancy by adding required tenant columns.
Hi Maxim
Thanks for the info. It will be appreciated if you please list the Entities relevant for getting the email template working in a multitenant environment.
Thank you Maxim.
I have currently extended
@JmixEntity
@DiscriminatorValue("erp$ExtEmailTemplate")
@NamePattern("%s|name")
@Entity(name = "erp$ExtEmailTemplate")
public class ExtEmailTemplate extends JsonEmailTemplate {
private static final long serialVersionUID = -1482560931655145667L;
@TenantId
@Column(name = "TENANT_ID")
protected String tenantId;
public void setTenantId(String tenantId) {
this.tenantId = tenantId;
}
public String getTenantId() {
return tenantId;
}
}
I guess this will work, thanks for your comments or suggestions if any.
I noticed that JsonEmailTemplate is extended from EmailTemplate entity, therefore, I might not need to extend EmailTemplate, is that right or still need to extend?
My second point is, EmailTemplatesAPI
is not found in the new version of Add-on that I used in the previous version, is it removed? If so, which API is replacing that to send email using email template?
This is what I am trying to migrate to JMIX as follows:
emailTemplatesAPI.buildFromTemplate(CREATED_TEMPLATE_CODE)
.setTo(emailAddressTo)
.setSubject(extEmailTemplate.getSubject())
.setBodyParameter("linkParameter", linkString)
.setBodyParameter("userFirstName", actor.getFirstName())
//.setBodyParameter("lastName", actor.getLastName())
.sendEmail();
It seems that you need to extend JsonEmailTemplate and ReportEmailTemplate. Also pay attention to the @ReplaceEntity
annotation.
You should use the EmailTemplates
interface, it is described in the documentation.
Thank you.
Ok, I will choose “replace parent” when I’m extending those Entities to my ones in the studio.