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.
This entry was posted
on Monday, July 5th, 2010 at 11:45 am and is filed under Tutorial.
You can follow any responses to this entry through the RSS 2.0 feed.
You can leave a response, or trackback from your own site.
#1 by yves Benigot on July 6th, 2010
Quote
We did that in Java. This solution is somewhat simpler to implement than ours, although I would be delighted to let the user configure freely in the XP wether he or she wants email notification upon task assignment, without having to wire a connector for every task in the workflow.
#2 by Camille Hamel on August 6th, 2010
Quote
Thank you , this is of great help , it would be even greater if you could add a sample email acess line for LDAP as that’s what i’m using for Authenticating .
#3 by krunal on September 9th, 2010
Quote
hey
@ yves Benigot
can you brief me how you did in java. I am looking same sort of scenario
thanks
#4 by justine on May 9th, 2011
Quote
I wish to send an e-mail via a connector to a group knowing that the sendinfg of this e-mail isn’t made from the actor of the task.
Could anybody help ma to find the right code Java.
thanks