Customize email template

cancel
Showing results for 
Search instead for 
Did you mean: 
rich1
Member II

Customize email template

Jump to solution

When starting a workflow, there is an checkbox for sending a email notification. We would like to customize that email with our own email-template. How do we that without changing the default template?

1 Solution

Accepted Solutions
krutik_jayswal
Senior Member II

Re: Customize email template

Jump to solution

There are two files which are responsible for sending the email notification in alfresco.

  1. community-edition-old/WorkflowNotificationUtils.java at master · Alfresco/community-edition-old · Gi... 
  2. community-edition-old/TaskNotificationListener.java at master · Alfresco/community-edition-old · Git... 

You need to extend above two files.

TaskNotificationListener is having one function named as notify, that is the function in which you need to add all the custom variables/properties which you want to use in ftl template.So for example if you would like to add some custom property named as inv:invoice_number in the email then you can fetch it in this files and add it in variable.Finally inside this function it is calling a method which is in WorkflowNotificationUtils.

WorkflowNotificationUtils contains many function, you can create one of yours and call that from your notify function which is in TaskNotificationListener.WorkflowNotificationUtils  also defines the template , so you can change that as well.

For extending above two files , you need to create beans as per below in service-context.xml

<bean id="customWorkflowNotification" class="com.alfresco.repo.workflow.CustomWorkflowNotificationUtils">
         <property name="workflowService" ref="workflowServiceImpl"/>
         <property name="nodeService" ref="NodeService"/>
         <property name="notificationService" ref="NotificationService"/>
</bean>

<bean id="activitiTaskNotificationListener" class="com.alfresco.repo.workflow.activiti.tasklistener.CustomTaskNotificationListener" depends-on="activitiWorkflowManager">
         <property name="propertyConverter" ref="activitiPropertyConverter" />
         <property name="workflowNotification" ref="customWorkflowNotification" />
         <property name="nodeService" ref="NodeService"/>
         <property ref="PersonService" name="personService" />
         <property ref="AuthenticationService" name="authenticationService" />
</bean>

View solution in original post

3 Replies
krutik_jayswal
Senior Member II

Re: Customize email template

Jump to solution

There are two files which are responsible for sending the email notification in alfresco.

  1. community-edition-old/WorkflowNotificationUtils.java at master · Alfresco/community-edition-old · Gi... 
  2. community-edition-old/TaskNotificationListener.java at master · Alfresco/community-edition-old · Git... 

You need to extend above two files.

TaskNotificationListener is having one function named as notify, that is the function in which you need to add all the custom variables/properties which you want to use in ftl template.So for example if you would like to add some custom property named as inv:invoice_number in the email then you can fetch it in this files and add it in variable.Finally inside this function it is calling a method which is in WorkflowNotificationUtils.

WorkflowNotificationUtils contains many function, you can create one of yours and call that from your notify function which is in TaskNotificationListener.WorkflowNotificationUtils  also defines the template , so you can change that as well.

For extending above two files , you need to create beans as per below in service-context.xml

<bean id="customWorkflowNotification" class="com.alfresco.repo.workflow.CustomWorkflowNotificationUtils">
         <property name="workflowService" ref="workflowServiceImpl"/>
         <property name="nodeService" ref="NodeService"/>
         <property name="notificationService" ref="NotificationService"/>
</bean>

<bean id="activitiTaskNotificationListener" class="com.alfresco.repo.workflow.activiti.tasklistener.CustomTaskNotificationListener" depends-on="activitiWorkflowManager">
         <property name="propertyConverter" ref="activitiPropertyConverter" />
         <property name="workflowNotification" ref="customWorkflowNotification" />
         <property name="nodeService" ref="NodeService"/>
         <property ref="PersonService" name="personService" />
         <property ref="AuthenticationService" name="authenticationService" />
</bean>

emadhusam
Customer

Re: Customize email template

Jump to solution

Thank you for that.
and how can I use this custom notification? in other words how to override the default one

fedorow
Senior Member II

Re: Customize email template

Jump to solution

What do you mean:

How do we that without changing the default template?

If you don't need to change workflow, you just upload new version of template.

Repository> Data Dictionary> Email Templates> Workflow Notification> wf-email.html.ftl

Default template stay in the system in version 1.0.