Create a list of checkboxes - 6.4.2

Hi.
Is there a way to create a list of users with their own checkbox associated ?
Many thanks, bye.

Chiara.

Hi.
You need to add a “CheckBox list” widget in your form.
In the “Data” tab of this widget, you need to add the user list in the “available value” field.
To have the list of users, you can use this script :

import org.bonitasoft.engine.identity.User;
import org.bonitasoft.engine.identity.UserCriterion;

int nbUser = apiAccessor.getIdentityAPI().getNumberOfUsers();

List userList = apiAccessor.getIdentityAPI().getUsers(0, nbUser, UserCriterion.USER_NAME_ASC);

List userNameList = new ArrayList();

for (User user : userList) {
userNameList.add(user.getUserName());
}

return userNameList;

Thank you ! Now I can see the users list !

Can I ask you one more thing ?

How can I save the “check” value to send it to another form ?

These are my first steps with Bonita, and I’m trying to learn.

Thanks again.
Chiara

You need to create a List variable in your Process. (I will name it selectedUserList)
Then in the form, go in the “Data” tab of the “CheckBox list” widget.
You can see something like :
“Output Operation [anEmptyField] Takes value of [anEmptyField]”
In the first field, select the selectedUserList variable that you just create. And in the second field, choose your field_checkboxlist.

Like this, the selectedUserList variable contains all the names that are checked in the form. And you can use this list in every other task of your process.

Thanks a lot for your help!

Sorry again if I ask you one more question. Is there a way to make “Actor” of the task the user who checked in the checkbox?

Thanks!

Sorry to bother you, where do you put this script ?
In the " Task 1 " I have a list of checkboxes and I would that the actor of the Task2 was the one previously selected in the Task1.
If I put this script on the " Task2 - Action filtrer" this gave me an error.
Where am I wrong?

Thanks a lot!

EDIT : I copy the wrong script. See the answer below for the good script.

I copy the wrong script in my last answer.
To assign a task to a user, you need to put this in the “Actor Filter” :

Long idUser;
try {
idUser = apiAccessor.getIdentityAPI().getUserByUserName(userName).getId();
} catch (Exception e) {
}
return idUser;

If the selected user doesn’t exist, the api will send an Exception and you can assign the task to another user in the “catch”.