Send a notification email to candidates of a task

rlg's picture
rlg

A frequently asked question in the community is how to send a notification email to candidates when a new task is created. This article describes how to quickly do that by using the user management included in Bonita User Experience.

Prerequisite

You have to provide an email for users in the Bonita User Experience. You need a smtp account in order to send emails.

What you will do?

You will configure a task to send an email to all its candidates. The email will contain a link to perform the task.

How to do that?

You have to add a new send email connector on the enter event of the task. Then you have to configure your smtp access and fill the email configuration page with the values below:

From direct value YourSender@Email.com
To Groovy
import org.ow2.bonita.util.AccessorUtil def candidates = AccessorUtil.getQueryRuntimeAPI().getTaskCandidates(activityInstance.getUUID()) def to="" for(user in candidates){ if(to!="") to+="," // If Emails are not stored in Bonita User Experience, please adapt the next line to get email from your system to+=AccessorUtil.getIdentityAPI().getUser(user).getEmail() } return to
Subject Groovy
activityInstance.getDynamicLabel()==null?activityInstance.getActivityLabel():activityInstance.getDynamicLabel()
Message Groovy
import providedscripts.BonitaURLs; out="A new task was assigned to you:\n" out+=(activityInstance.getDynamicDescription()==null?activityInstance.getActivityDescription():activityInstance.getDynamicDescription())+"\n" out+="\n\nPlease click on next link to perform your task:\n" // Please adapt the next line to your environment: the host and the port of your application out+=BonitaURLs.getStepURL("localhost","9090",processDefinition,activityInstance) out+="\n\n-- \nYour quality team\nhttp://www.bonitasoft.com"

And that's all. Now when the task is created, an email will be sent to all candidates.

You can download the Send notification email example if you want to quickly test this example.

Comments

Submitted by cleitonjar on Sat, 12/19/2015 - 03:13

I liked this.
It is work.

Submitted by claudio.taragnolini on Tue, 03/28/2017 - 18:47

Hi, sorry but the code that u wrote here does not work anymore with latest version of BonitaSoft. can u give us an update? thanks..

Notifications