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?
Solved! Go to Solution.
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>
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>
Thank you for that.
and how can I use this custom notification? in other words how to override the default one
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.
Ask for and offer help to other Alfresco Content Services Users and members of the Alfresco team.
Related links:
By using this site, you are agreeing to allow us to collect and use cookies as outlined in Alfresco’s Cookie Statement and Terms of Use (and you have a legitimate interest in Alfresco and our products, authorizing us to contact you in such methods). If you are not ok with these terms, please do not use this website.