Send Email to task assignee with task name & link

1
0
-1

My ask is simple, I want to send email to task owner as soon as a task is assigned to him or her. The email subject should contain name of the task and if possible link to it. What I have was able to achieve so far is below

Create email connector which executes on start of task To get dynamic task name I tried using below code

apiAccessor.getProcessAPI().getActivityInstance(activityInstanceId).displayName)

but this always returns null. Any thoughts ?

4 answers

1
+2
-1

At the moment when connector is executed on enter, dynamic name is still not available, that is why it returns null value. You can use getName() method, that will get the name of the task, or you can use the same expression as you put in the Display name of the task (script, variable etc.). That way you would be able to produce the same name as it will be done for the display name once the task becomes available.

Comments

Submitted by dhananjay.manohar on Wed, 05/07/2014 - 11:59

Yes this works Thanks! Now coming to other part of my question how do I get link to task in email body ?

Submitted by haris.subasic on Wed, 05/07/2014 - 12:47

You will find how to get a task url in our online documentation here .

Submitted by kppatel on Thu, 05/08/2014 - 07:01

Thank you for provideing link . but i can't figured out at where i have to write that code .

i m writeing that code on email body : script editior

gives following warning : buffer cannot be resolved. It may lead to run time errors.

StringBuffer buffer = new StringBuffer("URL: <a href=\"");
buffer.append("http://");
buffer.append(host);
buffer.append(":");
buffer.append(port);
buffer.append("/bonita?ui=form&locale=en#form=");
buffer.append(processName); buffer.append("--");
buffer.append(processVersion); buffer.append("--");
buffer.append(activityName); buffer.append("$entry&mode=app&task=");
buffer.append(activityInstanceId);
buffer.append("\">here</a>");
return buffer.toString();

at at execution it fails

Submitted by haris.subasic on Fri, 05/09/2014 - 15:06

Try to switch editor from Wysiwyg (rich text) to expression editor and create a script that will generate this html code.

Submitted by kppatel on Sat, 05/10/2014 - 08:37

thank you for reply but i can't elobare how to do it .

i create email connector and in message (body) click on switch to editer . then i click on pencil icon for go to ediotor then expresion type : script interpreter : groovey and paste code

StringBuffer buffer = new StringBuffer("URL: <a href=\"");
buffer.append("http://");
buffer.append(host);
buffer.append(":");
buffer.append(port);
buffer.append("/bonita?ui=form&locale=en#form=");
buffer.append(processName); buffer.append("--");
buffer.append(processVersion); buffer.append("--");
buffer.append(activityName);
buffer.append("\$entry&mode=app&task=");
buffer.append(activityInstanceId);
buffer.append("\">here</a>");
return buffer.toString();

when try to execute eamil connector give following error

java.lang.reflect.InvocationTargetException
org.bonitasoft.engine.bpm.connector.ConnectorExecutionException: org.bonitasoft.engine.core.connector.exception.SConnectorException: org.bonitasoft.engine.expression.exception.SInvalidExpressionException: Declared return type class java.lang.Long is not compatible with evaluated type class java.lang.Integer for expression activityInstanceId

pl help

Submitted by babiecasw on Wed, 06/04/2014 - 22:53

hey, have you found a solution to this???

Submitted by yassine.zekri1994 on Fri, 06/24/2016 - 11:03

Hi,me too i want to know the solution.

regards
Yassine

1
+1
-1

Hi,

I used the following:

String body = "Estimado usuario:<br/><br/>"
body += "Le ha sido asignada una nueva tarea, de clic ";
body += "<a href=\"http://procesos:8080/bonita?ui=form&locale=en#form=";
body += apiAccessor.getProcessAPI().getProcessDefinition(processDefinitionId).getName();
body += "--";
body += apiAccessor.getProcessAPI().getProcessDefinition(processDefinitionId).getVersion();
body += "--";
body += apiAccessor.getProcessAPI().getActivityInstance(activityInstanceId).getName();
body += "\$entry&mode=app&task=";
body += activityInstanceId.toString();
body +="\">aquí</a>"
body += " para más información.<br/><br/>";
body += "Cordialmente.<br/>"
body += "El equipo de Procesos.";

return body;

and it worked for us.

IMPORTANT you need to use a "\" (slash) before $ in the line "entry&mode" because in other way Groovy try to use an object called "entry".

Lucky!

1
0
-1

Try
apiAccessor.getProcessAPI().getActivityInstance(activityInstanceId).getName()

1
0
-1

You should try the following code instead:

apiAccessor.getProcessAPI().getActivityInstance(activityInstanceId).getDisplayName()

Comments

Submitted by dhananjay.manohar on Wed, 05/07/2014 - 10:03

I had already given that a try the result is same. The same code works in a plain old groovy script, but not within email connector.

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

Show. Realy work.

Notifications