List component with Ignition User names

Hi,

I’m trying to populate a List component with all Ignition users that have a particular role.

For a bit of context, the list will contain a list of all ‘wine maker’ users. Selecting one or multiple wine makers will then filter a list of tanks (template repeater) to show only tanks assigned to those selected wine makers. I can easily achieve this by either using a static dataset or querying a SQL table, but I’d like to be able to link it to Ignition users instead.

I can see that I could do this using Python (system.users.getUsers("")), however I don’t know how to populate the list dataset via a python script. Is this possible?

Hello,

You could add something like this to your internalFrameActivated event:

[code]headers = [“User Name”]
data = []

users = system.user.getUsers("")
for user in users:
roles = user.getRoles()
for role in roles:
if role == “wine maker”:
data.append([user.get(user.Username)])

user_dataset = system.dataset.toDataSet(headers, data)

system.gui.getParentWindow(event).getComponentForPath(‘Root Container.List’).data = user_dataset[/code]

1 Like

Thanks! This works great.