How to show the list of users in the form

1
0
-1

Hello
I'm new in the Bonita world and have a question about showing the list of users in the form.
In the model (BDM object) I have a list of user's id and in the form I need to show this list (First name, Last name, userName, etc)

As far as I understand, in the REST API identity/user the only way is to query user one by one - by single Id.
The only way to make a query in the form (as far as I understand) is to use form's Variable (Javascript expression, External API, String, JSON, URL parameter)

using External API type I can create variable for single user, i.e ../API/identity/user/{{CheckList.author}}
but I have to show the list of users (CheckList.approvers)
What is the correct way to do it?

of course, in the Javascript I can make a loop over the ids, but how to make a call to the identity/user for particular userId as parameter?

3 answers

1
0
-1
This one is the BEST answer!

I have found the acceptable solution for me:
I have created process variable pAssignedUserList (java.util.List) and populated it before human task.
in the human task I use the custom widget http://community.bonitasoft.com/project/get-activity-variable to get the process parameter into form variable (AssignedUserList).
this variable then is used to get required attributes in the form.

so in the form I have created variable Approvers Javascript and use it in the table widget

var ids = $data.CheckList.approvers; // this is the id's list
var allUsers = $data.AssignedUserList.value; // this is the prepared by the custom widget User's list
var users = [];
for(var i in allUsers){
var user = allUsers[i];
if(ids.indexOf(user.id) > -1) users.push(user);
}
return users;

without that custom widget I had a wrong format of object - just a big String instead of JSON array (see http://community.bonitasoft.com/questions-and-answers/how-add-process-va...)

1
0
-1

I have a question on this same concept.

first I want to show a list of my users in a checkbox list in a form and choose some of them to act as an actor in my next human task.can u help me with this scenario, please?

1
0
-1

I think you're over thinking this slightly.

You say you have your userIDs already in a BDM...

why not just populate the BDM (or another BDM) with the names of the people first, before the page, rather than after. You can use a script connector to do this. Done.

Hope this helps,
regards
Seán

PS: if this answers your query please mark as Resolved

Comments

Submitted by ykuzmenko73 on Tue, 12/29/2015 - 07:56

Sean, thank for quick response.
In BDM I need only user ID's, not all user's information that might be required on the UI form later.

Today I need First name, Last name, userName. tomorrow I will have to add information about their manager, group and so on. In suggested approach I will have to change the BDM, repopulate it etc
by the way if the name of the user will be changed, the stored in the BDM copy will obsolete etc.

so the question is quite common: I have a id's of the some objects and I have to display the list of objects with such ID's

Submitted by Sean McP on Tue, 12/29/2015 - 08:41

What I actually said was,

why not just populate the BDM (or another BDM)

In this case OK, leave your original BDM alone and keep it to ids only (meets requirement In BDM I need only user ID's). But you should create a second (temporary) BDM (version1) for the names etc. and use this in your form.

If you don't want to use a BDM, use a process variable...just as easy and will meet al your requirements for obsolescence etc. Yes it will be recreated everytime...but if that's what's required.

If you use a BDM then you can create v2, v3 etc.

This will be the easiest way of creating updates and ease modification at a later date.

NOTE: I always use a version number on BDMs If you change a BDM it will/can destroy data if modified incorrectly. This way old processes can co-exist with new.

for minor - none-changing modifications
myBDM_v01m00
myBDM_v01m01
myBDM_v01m02
etc.

for major - changes (adding fields, deleting fields, new custom queries etc.)
myBDM_v01m00
myBDM_v02m00
myBDM_v03m00

regards
Seán

Submitted by ykuzmenko73 on Tue, 12/29/2015 - 09:13

Sean, thant you very much for swift responses.

I have found the acceptable solution for me:
I have created process variable pAssignedUserList (java.util.List) and populated it before human task.
in the human task I use the custom widget http://community.bonitasoft.com/project/get-activity-variable to get the process parameter into form variable (AssignedUserList).
this variable then is used to get required attributes in the form.

so in the form I have created variable Approvers Javascript and use it in the table widget

var ids = $data.CheckList.approvers; // this is the id's list
var allUsers = $data.AssignedUserList.value; // this is the prepared by the custom widget User's list
var users = [];
for(var i in allUsers){
var user = allUsers[i];
if(ids.indexOf(user.id) > -1) users.push(user);
}
return users;

without that custom widget I had a wrong format of object - just a big String instead of JSON array (see http://community.bonitasoft.com/questions-and-answers/how-add-process-va...)

Notifications