Actor filter single user not working

Dear Sir/Mdm,

How do i use actor filter? Tried but not working.

Terry

import org.bonitasoft.engine.identity.User;
User user =apiAccessor.getIdentityAPI().getUserByUserName(“username”);
return user.getId();

Put above code in single user actor filter and you would be able to assign single user for given task.

  • Akhilesh

Hello ,
My be this help you

create one data variable:uid with datatype : long (that will store single user’s id)

now,
in first task’s form take one select box , in available value paste following code .
that will give list of all available user

import org.bonitasoft.engine.identity.*;

List users = apiAccessor.getIdentityAPI().getUsers(0, 200, UserCriterion.FIRST_NAME_ASC);
Map<String,Long> combo = new HashMap<String,Long>();

for(User u:users)
{
combo.put(u.getFirstName(),u.getId());
}

return combo

now,
in output operation :
first filed - select that variable (uid) takes value of field - click on pencil (script) paste following

def long l = Long.parseLong(field_Select1);

task 2 → actor → set actor filter → add Uid variable

Run process ,
thanks
kandarp

return type :
should be : java.util.map

thanks
kandarp

Whoever is interested,

I found the solution.
I have a process variable “uid” datatype "long’. Its passed to actor filter. So to grab the email details of userid and passed to system task email connector, just placed the codes below in groovy script.

import org.bonitasoft.engine.identity.User;
import org.bonitasoft.engine.identity.ContactData;
import org.bonitasoft.engine.bpm.actor.ActorCriterion;

// Get the users attached to the actor member of the human task
BonitaUsers.getUserProfessionalContactInfo(apiAccessor,uid).email

Regards,
Terry

Hi Akhilesh,

I have a process variable called “usernames” as a list with default values (user1, user2).

import org.bonitasoft.engine.identity.User;
List users = apiAccessor.getIdentityAPI().getUsers(0,200, usernames);
Map<String,Long> list = new HashMap<String,Long>();

for(User u:users)
{
list.put(u.usernames(),u.getId());
}
return list

I have inserted this to actor filter, single user, groovy script but still doesnt work.

Terry

Hi Kandarp,

I followed your suggestion. However, when i run the process in the portal, I get an error “Error while getting the form page list.”

pic1

The screenshot for first task’s form take one select box , in available value paste following code as follow

pic

Is the return type correct?

Regards,
Terry

Hi Kandarp,

Tks. It works for actor filter. However, I have a email connector. How do i grab the email address of the selected userid ?

Terry

Hi Kandarp,

Tks. It works for actor filter. However, I have a email connector. How do i grab the email address of the selected userid ?

Terry

I have tried to grab email address of the userid with the following code but still doesnt work.

import org.bonitasoft.engine.identity.*
UserWithContactData proUser = getIdentityAPI().getUserWithProfessionalDetails(user.getId());
proUser.getContactData().getEmail();

Any advise.

Terry