cancel
Showing results for 
Search instead for 
Did you mean: 

Retrieve user email for given user id in bpmn process

pushpindersingh
Champ in-the-making
Champ in-the-making
Activiti version: Activiti-5.15
Tomcat: 7.0.42

Hi all,
I need to retrieve user email in 'Email Task' in bpmn process to forward email to given user id entered in initial form.
I wonder what is best practice to do in bpmn file and how to do it?

We are evaluating Activiti as process engine for our coming project.
I am able to run bpmn process (designed using Activiti designer) with hard coded user id and emails.

Now next steps to get user email for given user id in 'Email Task' to set 'To' field in Main Config.

I will appreciate any hint or link solving above problem.

3 REPLIES 3

pushpindersingh
Champ in-the-making
Champ in-the-making
I come across advise to use the identity service from a service task to retrieve details about a specific user, including the email address. Now question is how to get identityService variable. Is it available by default in service task. If not then how to get identityService variable? and where to put whole code?

trademak
Star Contributor
Star Contributor
Yes you can retrieve the EngineServices on the DelegateExecution and from there retrieve the Identity service.

martijn
Champ in-the-making
Champ in-the-making

Hi guys,

I am also trying to get the username of a user. I am using the identityservice in a scripttask, like this:

var idService = processEngine.getIdentityService();
var keys = idService.getUserInfoKeys(person);

However, the 'var keys' is empty. The 'person' variable should be the userId. 

I got this userId like this:

var person = execution.getVariable('personField');

Where personField is a formField where I can select a single person. The userId is something like '2002' in my case. Is this correct, or do I maybe have a formFieldId or something?

Best regards,

Martijn