cancel
Showing results for 
Search instead for 
Did you mean: 

Use of liferay notification portlet with Activiti BPM

montej
Champ in-the-making
Champ in-the-making
I am using activiti BPM in liferay for workflow.
I am currently created some task in activiti diagram.
when in workflow user create content then i want to give him notification.
I create activiti diagram so user get email notification.But i also want to give me notification him with liferay notification portlet.
How can i do that?
Is there any properties to cinfigure in Acitviti task or write some script?
Any help will be appriciated. 
6 REPLIES 6

vasile_dirla
Star Contributor
Star Contributor
Hi Montej,
So you would like to receive the notifications inside the Notifications portlet.
In this case I think you should use a ScriptTask with a groovy script or a ServiceTask with a java delegate class.
anyway.. you choose what you prefer (I would go with a service task)
this custom "action" should create a new UserNotificationEvent with a call like:
<java>
UserNotificationEventLocalServiceUtil. addUserNotificationEvent(userId, notificationEvent);
</java>
which will be read later by the Notifications portlet.

I didn't implement a test for this approach but i just had a look over the portlet sources and I think will work.

montej
Champ in-the-making
Champ in-the-making
Thanks for your reply, I will try with this trick.
But can i get built in  notificationEvent object or i have to create it in script?
I know that userId i can get directly but not sure about notificationEvent.

vasile_dirla
Star Contributor
Star Contributor
Hi,
the notificationEvent is a new object you should create it here inside your script/delegate class.

since the NotificationEvent class is loaded in the portal classLoader, you are able to create a new object in any of the portlets. (as you know the portlet class loader is a child of the portal classloader)

montej
Champ in-the-making
Champ in-the-making
Thanks vasile.dirla getting nice detail from you

montej
Champ in-the-making
Champ in-the-making
Hi ,
i am getting userId by <activiti:expression>#{userId}</activiti:expression>
I want to get "workflowInstanceId" and "workflowTaskId" id for setting up jsonObject for creating NotificationEvent.
So is there way to get this variable ?

montej
Champ in-the-making
Champ in-the-making
I have got solution for notification send when task assgin to user.
Only enable email notification by following code ,the notification in notification portlet display by it self.  
<serviceTask id="servicetask1" name="Send Mail" activiti:type="mail">
      <extensionElements>
        <activiti:field name="to">
          <activiti:expression>#{liferayService.getUserEmail(userId)}</activiti:expression>
        </activiti:field>
        <activiti:field name="subject">
          <activiti:expression>Review Task</activiti:expression>
        </activiti:field>
        <activiti:field name="html">
          <activiti:expression>Review the below task</activiti:expression>
        </activiti:field>
      </extensionElements>
    </serviceTask>