Get email address of current user

1
0
-1

Good day

I am using v6. I have a connector on finish of a service task to send an email notification to a specific user. I want to use the current users email address as 'from email address'. I tried the following script but it doesnot work. Please help me on what script to use. BonitaUsers.getUserProfessionalContactInfo(apiAccessor,taskAssigneeId)

Also I have a connector to send email to the next task assignee (next task is a human task). Where should I put the connector, on enter of the next task? and what script will i use?

Thank you!

Comments

Submitted by solo786 on Fri, 06/06/2014 - 07:15

I want to do this too! Please help.. Thank you!

3 answers

1
0
-1
This one is the BEST answer!

Hello,

your script does not work, because there is no user for a service task (thus, no taskAssignee for that task). You might want to put your email connector on the onFinish of the previous task, where you should be able to use your script in order to retrieve the address of the assignee. Otherwise, you will have to retrieve the user id in another way. If it is the process initiator, you could use BonitaUsers.getProcessInstanceInitiator(apiAccessor,processInstanceId).

And to send email to the next task assigne, you can put an email connector on the enter event of the next task and you can find some more information about script for a task url on this thread .

Hope this helps, Haris

Comments

Submitted by garciarenier on Mon, 06/09/2014 - 13:16

Hi, Thanks for the response. Regarding 'fromEmail', this will always be the same as the username used for authentication whenever you use gmail as email server.

On the next task assignee, it is working but there is a BPMN 2 Compliance issue.

Thanks

1
+1
-1

Hi Renier,

When you want to put an email connector on a human task, you have a error (not BPMN2.). The solution is to do like in my example I think (see picture). http://www.hostingpics.net/viewer.php?id=6406644301.png

  • Create a global variable on your pool.

  • On task 2, create an Operation (General tab --> Last option, just after connector), link it to your variable and put the following script : "return BonitaUsers.getUserProfessionalContactInfo(apiAccessor, taskAssigneeId).getEmail();"

  • On task 3 (connector), in the from field, place your variable.

1
0
-1

Hi

I tried putting connector on enter of a task however i always fails. per log, here is the cause.

Caused by: java.lang.NullPointerException: Cannot invoke method getEmail() on null object at org.codehaus.groovy.runtime.NullObject.invokeMethod(NullObject.java:77) at org.codehaus.groovy.runtime.callsite.PogoMetaClassSite.call(PogoMetaClassSite.java:45) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.NullCallSite.call(NullCallSite.java:32) at org.codehaus.groovy.runtime.callsite.CallSiteArray.defaultCall(CallSiteArray.java:42) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:108) at org.codehaus.groovy.runtime.callsite.AbstractCallSite.call(AbstractCallSite.java:112) at Script2.run(Script2.groovy:1) at org.bonitasoft.engine.expression.impl.GroovyScriptExpressionExecutorCacheStrategy.evaluate(GroovyScriptExpressionExecutorCacheStrategy.java:97) ... 19 more

Thanks!

Renier

Notifications