02-13-2018 07:47 AM
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?
02-13-2018 10:58 AM
There are two files which are responsible for sending the email notification in alfresco.
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>
02-13-2018 10:58 AM
There are two files which are responsible for sending the email notification in alfresco.
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>
09-02-2019 03:08 AM
Thank you for that.
and how can I use this custom notification? in other words how to override the default one
09-02-2019 06:32 AM
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.
Explore our Alfresco products with the links below. Use labels to filter content by product module.