In one of my previous blogs I wrote about how to setup email settings and configure Web Content notifications triggered by workflow.
Liferay portal 6.1 relays to external workflow engine Kaleo which also has ability to send notifications. As our intention is to centralize workflow related code in Kaleo and users workflow definitions, eventually we will remove legacy workflow notifications (such those in web content managment). So to prepare you for things that are comming check this blog.
Kaleo
To constrain your business process with some rules, you need:
- rules
- language to describe those rules to mchine
- workflow engine
- assets and resources aware of workflow engine
- people who want to play by the rules
Kaleo and Liferay give us 1*, 2, 3, 4*. Once you have idea what are yours company rules, you will ask somebody to write definition in an xml like language. Than you will run those rules in portal and apply it to you asset and resources.
What is interesting you will probably want some actions performed to asset to trigger messages to get users attention. You want to notify user there is job to do, he done great job or there is awful escalation that needs immediate intervention. As part of workflow definition you will be able to create some actions eather real scripted actions or notifications. Notifications can be emails, instant messages or private messages. In the rest of blog I will focus on email notifications.
Kaleo email notifications
As kind of action we form notifications as part of process state or tasks. Triggering of notification is done in a three ways:
- on assignment - when task is assigned to user
- on entry - when asset enters some state or is ready for an task within state
- on exit - when asset leaves the state or all job required by the task is done by particular user
At the end we must choose do we need some simple messages in our email or we want to build more specific messages aware of business and workflow context. Kaleo definitions will allow you to write messages as plain text but in most cases that wouldn't be enough. also for advanced users there is possibility to do that in freemarker or velocity.
Write your own notifications
For example I'll existing default single-approver-definition.xml notification defined for review task. New notification will use new email subject and will include some data related to asset that is being workflowed. My new notification related to review task is following:
<notification>
<name>Review Notification</name>
<description>New Submission Is Ready For Review</description>
<template>
<![CDATA[
Please review the ${entryType} waiting for you in your workflow tasks.
<#if comments != "" >
<br />Assignment comment says: <strong>${comments}</strong>
</#if>
</p>
<p>Sincerely,<br /><strong>Liferay Portal Workflow</strong></p>
]]>
</template>
<template-language>freemarker</template-language>
<notification-type>email</notification-type>
<execution-type>onAssignment</execution-type>
</notification>
Now, lets go step by step:
node name - it will just define notification identification name
node description - it serves as description, but kaleo will populate an email subject field with its value so be as more creative when you setting this value
node template-language - tells kaleo to use freemarker engine to merge template and data
template - there are two things to note. First it is assignment of variable comment:
<#assign comments = taskComments!"">
expression taskComments!"" will take value from freemarker context variable taskComments and if it is null en ampty string will be returned. We have to do that because when initaly enters review task, it is done by engine so there won't be available taskComments. In moment when manager assigns task to user he will be prompted to set comment so we will be able to display comment inside email message.
Second thing is use of freemarker context variable entryType. Expression ${entryType} will be evaluated as asset type like Web Content, Comment or Wiki.
This is how received email looks now:
For next time I will display how to make more advanced templates.

