Create a list of checkboxes - 6.4.2

1
0
-1

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

Chiara.

2 answers

1
+1
-1
This one is the BEST answer!

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<User> userList = apiAccessor.getIdentityAPI().getUsers(0, nbUser, UserCriterion.USER_NAME_ASC);

List<String> userNameList = new ArrayList<String>();

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

return userNameList;

1
0
-1

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

Comments

Submitted by yannick.lombardi on Wed, 03/25/2015 - 17:31

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.

Submitted by chiaraparpinello on Thu, 03/26/2015 - 10:03

Thanks a lot for your help!

Submitted by chiaraparpinello on Fri, 03/27/2015 - 11:23

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!

Submitted by chiaraparpinello on Mon, 03/30/2015 - 11:52

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!

Submitted by yannick.lombardi on Mon, 03/30/2015 - 11:59

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

Submitted by yannick.lombardi on Mon, 03/30/2015 - 12:03

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".

Notifications