cancel
Showing results for 
Search instead for 
Did you mean: 

How do I get user info from userID

vsangal
Confirmed Champ
Confirmed Champ

I have been researching and found out that this is the best way to current usr info from activiti DB. However, it comes out to be null.

This is my code..

First, I get userID

List<IdentityLink> identityLink = processEngine.getRuntimeService().getIdentityLinksForProcessInstance(processID);

Iterating through this I get userID

if (identityLink != null){

                    for (IdentityLink link : identityLink){
                        userID = link.getUserId();
                        logger.info("getProjectID:  userID ==== is " + userID);
                    }
                }else{
                    logger.info("getProjectID: userID is NULL ");
                }

Now I try to get userinfo, this is null.. Can someone help?

User user = processEngine.getIdentityService().createUserQuery().userId(userID).singleResult();

if (user !=null){    
                    logger.info("FirstName ======= " + user.getFirstName() );

                    logger.info("LastName ======= " + user.getLastName() );

                    logger.info("Email ======= " + user.getEmail() );

                    logger.info("Password  ======= " + user.getPassword() );
                }else{
                    logger.info("user  is ......................... NULL ");
                }

1 ACCEPTED ANSWER

cjose
Elite Collaborator
Elite Collaborator

Yeah, now it makes sense. When you add an attach file option in the form, the next task will turn async. That means it is no longer executed under the logged in user context! Hence you get null. Try executing your logic from an execution listener attached to the start activity or on the sequence flow if you really need the user context. It is not a bug, it is working as designed.

View answer in original post

15 REPLIES 15