how to get all usernames in a single JSON array. Is there any API to get all usernames. Thanks in advance please help me.
Hello,
There is no API call to retrieve only usernames. Do not hesitate to go to this documentation page identity API.
(preferred) Implement a new Custom REST API extension
Bonita enables you to add a new REST API extension. It would provide in the body of a HTTP response the information needed as JSON: I.E. a list of userNames. Please have a look to this documentation page: REST API extensions
(not preferred) out-of-the-box Solution
The existing API/identity/user
REST resource, available with a GET HTTP request, enables you to retrieve a JSON, containing detailed information of the users. If a tomcat is running locally on the 8080 port, the URL below can be used to retrieve up to 10000 users:
http://localhost:8080/bonita/API/identity/user?p=0&c=10000
UID FORM edition example
A UID form’s variable can be used to
- either sends a HTTP request and stores the JSON response: External API,
- or stores the result of the execution of javascript lines of code: javascript expression.
This example shows how to store the usernames of many users in a UID Form’s variable named allUserNames
.
Click on the Create a new variable button in order to create a variable with name allUsers, type External API, and value ../API/identity/user?p=0&c=10000
![Create new variable button UID][Create new variable button UID]Create a second variable with name allUserNames, type Javascript expression, value
var usernames = []; for (var i=0; i<$data.allUsers.length; i++) { usernames.push($data.allUsers[i].userName); } return usernames;
Regards,
Jerome
Hi Jerome,
thanks for reply actually from this we will get all the users from the organizations but I want only archieved usernames only.
For example i have three tasks user1 for step1 , user2 for step2 , user3 for step3 now I want user1 in step2 and also user1 and user2 in step3 . Thanks in advance.
var getAuditDetailJSON = ;
getAuditDetailJSON = $data.auditDetails;
var auditTrail = ;
for(var i= 0;i<getAuditDetailJSON.length;i++){
var userId = getAuditDetailJSON[i].executedBy;
var taskName = getAuditDetailJSON[i].displayName;
var dateTime = getAuditDetailJSON[i].archivedDate;
var user_name = ..API/identity/user/{{userId}}
var x = {user_name,userId,taskName,dateTime};
auditTrail.push(x);
}
return auditTrail;
please look into the above code which i created in javascxcript variable in ui designer i am displaying userId,taskName,date and userName, for username i am using var user_name = …API/identity/user/{{userId}} but i am not geetting username from this it is showing syntax error. Please help me is ther any other way to achieve this. Thanks in advance.
**
@ramireddy.pingala: The answer had been edited to clarify, I hope. To send HTTP requests, you need to use either javascript function either UID variables.
@ramireddy.pingala: The answer had been edited to clarify, I hope. To send HTTP requests, you need to use either javascript function (XMLHttpRequest) either a UID variable with type External API.
Hi,
Still I didn’t get any solution for this isssue, I solved this issue by saving the details into the database and retriveing through webService. I solved this problem like this.
Thank you