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

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

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.

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.

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

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

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.