Single user Actor Filter

Hi, i would like to user the “Single User” Actor Filter.

I am storing the username of the user which i would like to assign the task on field.

How could i retrieve the Id from the username trought a script to put inside the “Single User” Actor Filter Id?

Thanks

import org.bonitasoft.engine.api.IdentityAPI; import org.bonitasoft.engine.identity.User;

Long userid = identityAPI.getUserByUserName(userName.toLowerCase());
return userid.getId());

regards
Seán

PS: As this reply answers your question, please mark as resolved.

Hi sorry but i am not achieving my goal.

i put this code inside the script of “Single User” actor filter:

import org.bonitasoft.engine.api.IdentityAPI;
import org.bonitasoft.engine.identity.User;

Long userid = identityAPI.getUserByUserName(data.AreaManager);
return userid.getId();

where data is the name of my process variable and AreaManager is the field which contain the username of the user which i want to assign the task.

username is “walter.bates” or something similar that you sign in with.

Try that and then try to get the right data for your requirement…you’ll have to investigate for your issue, have you looked at the logs? What do they say…?

Hi, yes i know, and i am giving the username.

Log says:
org.bonitasoft.engine.core.filter.exception.SUserFilterExecutionException: org.bonitasoft.engine.expression.exception.SExpressionEvaluationException: Expression userId() with content = <import org.bonitasoft.engine.api.IdentityAPI;
import org.bonitasoft.engine.identity.User;
Long userid = identityAPI.getUserByUserName(data.AreaManager);
return userid.getId();> depends on identityAPI is neither defined in the script nor in dependencies.