Users Dropdown List

Trying to create a list of users to choose from to make login easier on a touchscreen. Having an issue. My user.Username property is coming in as “username” for all users. Here is the setup:

Custom dataset property on a popup window named “users”

on-window-open script:

userList = []

users = system.user.getUsers("")
for user in users:
	if user.Username != "admin":
		userList.append(user.Username)

userDataSet = system.dataset.toDataSet([''],[[x] for x in userList])

system.gui.getParentWindow(event).getComponentForPath('Root Container').users = userDataSet
system.gui.getParentWindow(event).getComponentForPath('Root Container').password = "*****"

The user dataset property is then bound to the data property of the dropdown box.

This is my result:
image
(I’ve also added a temporary table to see the dataset with the same data binding as the dropdown list)

Why do I get “username” for all of the users?

maybe try userList.append(user.get('username')). That’s how the example in the docs shows fetching properties from a user object

User is an interface that extends PropertySet, which is basically a multi-type map we use all over the place in Ignition.

The User interface defines various static property methods that are used elsewhere in Ignition to retrieve user attributes in a type-safe manner. Those interface constants are carried down to each instance of the User class, so the (probably) PyUser that you ultimately get in your script has those defined as fields.
Note these two methods on PyUser:

You can either call user.get(user.UserName) to use the first method, or user.get("username") to use the second method - which will simply look through the object's defined properties looking for a property with the given name (this means the first method is technically more efficient, but it's unlikely to ever really matter).

That seems to have worked, but the documentation for system.user.getUsers is not super clear.

https://docs.inductiveautomation.com/display/DOC/system.user.getUsers

You can access most of the basic user properties via a call to "get" or "getOrDefault" which returns a default value if the requested item is not present. For example:

user.getOrDefault(User.Schedule)

...will return that user's schedule, or the value of "Always" if no schedule has been set as that is the default schedule. The following are the various values you may use in this manner:

User.Username
User.FirstName
User.LastName
User.Notes
User.Schedule
User.Language
In addition to these properties, the user object has other methods on it to retrieve more information:

User.getId() - returns the internal identifier object that the backing user source needs to identify this user
User.getRoles() - returns a sequence of strings representing the roles that this user belongs to
User.getContactInfo() - returns a sequence of ContactInfo objects. Each of these objects will have a contactType and valueproperty representing the contact information, both strings.
User.getScheduleAdjustments() - returns a sequence of ScheduleAdjustment objects. Each of these objects will have two date properties, "start" and "end", a boolean property, "available", and a string property called "note".
User.getPath() - returns a QualifiedPath object that represents this user in a deterministic manner.

I'm able to access the properties, but how do you access the methods?
Thanks!

I'm afraid I don't understand this question. Methods are used in scripting along with fields, and they vary from class to class. What specifically are you wanting to do?