How can i get logged user id in a groovy script?

I'm trying to store some data in a process, in a mysql table. Among the data I want to save is the Id of the currently logged user.

How do I do this? 

I've been reading the documentation, but I can't find it for Bonita BPM 6.x. 

3 Likes

Did you have a look at our Javadocs ?

If you look for getUserId() in this index, you will find many usefull resource to use in groovy script to get the user ID.
http://documentation.bonitasoft.com/javadoc/api/6.0/community/common/index.html

you can do it for the getUser there I leave you an example

def firstname = apiAccessor.getIdentityAPI().getUser(loggedUserId).getFirstName();
def lastname = apiAccessor.getIdentityAPI().getUser(loggedUserId).getLastName();
//def caso = apiAccessor.getIdentityAPI.getCustomUserInfo(loggedUserId,1,1)
def caso = apiAccessor.getIdentityAPI().getUser(loggedUserId).getId();
def caso1 = apiAccessor.getIdentityAPI().getUser(loggedUserId).getManagerUserId();
def caso2 = apiAccessor.getIdentityAPI().getUser(loggedUserId).getJobTitle();
def caso3 = apiAccessor.getIdentityAPI().getUser(loggedUserId).getCreatedBy();
def caso4 = apiAccessor.getIdentityAPI().getUser(loggedUserId).getIconPath();
def caso5 = apiAccessor.getIdentityAPI().getUser(loggedUserId).getCreationDate();
def caso6 = apiAccessor.getIdentityAPI().getUser(loggedUserId).getManagerUserName();

return firstname+" “+lastname+” “+caso +” “+caso1+” “+caso2+” “+caso3 +” “+caso4+” “+caso5+” "+caso6;

Hello. I am trying to achieve the same thing as alonso.trejos and I am using the community edition 7.1.5. In the site you suggest it says that “Packages in org.bonitasoft.engine are available from Bonita BPM Community Edition, and also in Bonita BPM Subscription Editions. However, packages in com.bonitasoft.engine are only available for Bonita BPM Subscription Edition developers.” So when I am trying to write a groovy script and use the afforementioned package it displays that " The declared package “org.bonitasoft.engine” does not match the expected package." Is there any other way to get the Id of the current User?