Get Current user from Session

Hi,
I am trying to get the first name and last name of the user in session.

Can you please help.

Can we do it using connectors?

1 Like

Hello,

I think you should try with following :
import org.bonitasoft.engine.identity.User;

User user = apiAccessor.getIdentityAPI().getUser(loggedUserId);
String.format(“%s %s”, user.getFirstName(), user.getLastName());

Regards,
LL

I am trying the same thing,but how do I get the LoogedUserId

I tried it,It dint work.is there any other way?

I tried it,It dint work.is there any other way?

Hi,

We got the Username from the session,but only if it is a human task.My doubt is why doesnt it get the username from the current session in Service Task.

Does it hold the session from the time the task is started??Or is a session created only in a human task?

Thanks,
Charulatha

Hi,

U can try this script:

def firstname = apiAccessor.getIdentityAPI().getUser(loggedUserId).getFirstName();
def lastname = apiAccessor.getIdentityAPI().getUser(loggedUserId).getLastName();

return firstname+" "+lastname;

Put this script in submit button action. Work fine for me. Happy Hunting!
*U cant use connector because there is no human logged in that task

when you open your groovy expression editor you should be able to get it on the field
“Select a provided variable…” and in the list there is the LoogedUserId.

When a user executes a process, we know who is the logged user.

Could you please share the process you are using/implementing?
Thanks in advance.

Regards,
LL

thanks, I served