[UI-Designer] Display Rest API result in dropdown list

1
0
-1

Hello everyone,

I'm in front of a problem when i want to display users in a dropdown.
In UI-Designer, i have create an "External API" varriable with this url : '../API/identity/user?f="enabled"=true'

When i'm display this variable, it's show correctly:
{{usersAPI}} ==>
[{
"firstname": "Studio",
"icon": "icons/default/icon_user.png",
"creation_date": "2018-03-20 15:59:07.936",
"userName": "studio",
"title": "",
"created_by_user_id": "-1",
"enabled": "true",
"lastname": "",
"last_connection": "",
"password": "",
"manager_id": "0",
"id": "22",
"job_title": "Studio technical user for preview",
"last_update_date": "2018-03-20 15:59:07.936"
},....
]

So, in my dropdown list I fill attribute like that:
'available values' = users
'display key' = userName
'return key' = id

But, when i did it, my dropdown show the entire line of user:
{"firstname":"Studio","icon":"icons/default/icon_user.png","creation_date":"2018-03-20 15:59:07.936","userName":"studio","title":"","created_by_user_id":"-1","enabled":"true","lastname":"","last_connection":"","password":"","manager_id":"0","id":"22","job_title":"Studio technical user for preview","last_update_date":"2018-03-20 15:59:07.936"}

I allready try with :
'available values' = users | json
In this case, my dropdown show all characters....

Someone can help my about this ?

Thanks

Comments

Submitted by pierrick.voulet on Mon, 07/30/2018 - 22:46

Do you confirm that your "External API" variable is named "users"? If yes, maybe something wrong between "users" and "usersAPI"?

Submitted by bastien.laurent... on Tue, 07/31/2018 - 09:27

"usersAPI" it's an ExternalAPI.
"users" is just a test who are getting the result of usersAPI and try to transform to JSON object.

At the end, usersAPI = users.

But i have found the solution, i will write it after this post.

2 answers

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

Thx for your reply,

I have found the solution, and it's ridiculus...
In Bonita UI, when you create a 'dropdown', you can use 'fx' or 'X' in keys.
'fx' take a function or a part of your object, and 'X', just takes a cosntant.

So, when I'm selecting 'fx', the dropdown just work perfectly... It was a mistake who can use lot of time.

Comments

Submitted by pierrick.voulet on Tue, 07/31/2018 - 15:14

Good catch! On my side as a good practice I do force myself to use the autocompletion feature on the property input field when I want to bind to a variable, this to make sure it is well defined.

1
0
-1

As you can see there is "[]" brackets begin and end. Assign your users object's first item, like users[0] or use a javascript function to get data's from users and convert to json array.

Notifications