cancel
Showing results for 
Search instead for 
Did you mean: 

Task assignee is a number and not the user Name

srojas1
Champ in-the-making
Champ in-the-making
Hi

I have Activiti synced with LDAP (users and groups).

Using the Engine Java API I query for a Task and get the assignee. My surprise is that the assignee is a number and not the username I logged in with. I would like to know how to get the username also referred in Activiti as "External Id" from that number. The java code I use from a Class implementing JavaDelegate is:

execution.getEngineServices().getTaskService().createTaskQuery().processInstanceId("72581").singleResult().getAssignee();

The result is 3 but I do know that the username (External Id) is logger.

Just to give some more information, if I use the REST API to get the same task, the response comes with a JSON object for the assignee that in this case includes the External Id.

Have somebody had a similar issue or know the solution for this?

Thanks in advance and Regards

Sergio
5 REPLIES 5

srojas1
Champ in-the-making
Champ in-the-making
Hi Guys.

Any one had the chance to have a look into it please? Feel free to ask me for clarification if you do not understand my problem. Any help would be much appreciated

Thanks in advance and Regards

Sergio

srojas1
Champ in-the-making
Champ in-the-making
Hi All

Just figured it out myself. So the way of doing it is by using the UserService. I copy here my code in case is useful for any other person:

package com.activiti.extension.bean;

import org.activiti.engine.impl.pvm.delegate.ActivityExecution;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;

import com.activiti.service.api.UserService;

@Component("obtainDrafter")
public class ObtainDrafter {



@Autowired
    protected UserService userService;

public void giveDrafter(ActivityExecution execution) {
 
  long userId = new Long((Long)execution.getVariable("assignToDrafterdrafter")).longValue();
  String externalUserName = userService.findUser(userId).getExternalId();
  execution.setVariable("drafter", externalUserName);
 
}

}


jbarrez
Star Contributor
Star Contributor
Hi @srojas, moved this topic to 'Activiti Enterprise', the Activiti Developers is for internal development of Activiti.

There is also an alternative way: you can use the userInfoBean to resolve this id to a real user: https://docs.alfresco.com/activiti/docs/dev-guide/1.3.2/#_user_info_bean_userinfobean

The externalId you talk about above is the actual id in the user store. However, internally, only the db id is used for everything.

mohitsi
Champ in-the-making
Champ in-the-making
how to give external id to a user manually ?

jbarrez
Star Contributor
Star Contributor
You'd have to use the lower level services, get hold of the User entity and change the externalId that way. (for example via the UserService or UserRepository)