How to get users created in gateway in perspective dropdown

Hi Team

I have created users and roles in the gateway.
I want that usernames in the dropdown.

here in below script I am able to get list of users.
where I can bind in dropdown.
Please guide.

users = system.user.getUsers('default')
print users
validUsers = []

for u in users:
#    print u.getRoles()
    if 'Operator' in u.getRoles():
        validUsers.append(u.get('username'))
        
print validUsers

output in script console:
[u 'user1', u 'user2', u 'user3', u 'user4']

If you put the binding onto the options in the components props.

However for it to be valid each option needs a label and value field, in this case they'd be the same thing.

On the binding, you can put some kind of expression binding, maybe a long timer like now(10000), this is just the rate at which your options will refresh. You could bind this to anything really, like the current username if you don't want it to refresh after they logged in.

Put a script transform, and add in your code above, but to get the correct format append the extra code:

....
optionList = []
for user in validUsers:
    optionList.append({'value':user,'label':user})
return optionList

You could also just put this into previous for loop instead

1 Like

Thank you, I got the solution