# Get the list of all users in perspective

**URL:** <https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [October 26, 2021, 5:37pm UTC](https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358 "2021-10-26T17:37:10Z")\
**Posts on this page:** 10\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [October 26, 2021, 5:37pm UTC](https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358/1 "2021-10-26T17:37:10Z")

</div>

Hello everyone,

I am trying to create a user management component just like the vision one for my perspective view.

Vision user management component:

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/5/557270405184f9f3f9f5c8915b04b73410f56dfe.png)

I tried the link below to get the list of all users in my user table but I do not see any information to be populated.

[https://docs.inductiveautomation.com/display/DOC80/system.user.getUsers](https://docs.inductiveautomation.com/display/DOC80/system.user.getUsers)

I used print statements still do not get anything.

Appreciate any information you share on this.

```auto
	users = system.user.getUsers("")
	for user in users:
	    system.perspective.print(user.get('firstname') + " " + user.get('lastname'))

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 26, 2021, 6:03pm UTC](https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358/2 "2021-10-26T18:03:57Z")

</div>

How confident are you that the user in question has a defined first name and last name? When I ran this code I got some blank logging before realizing that the only users in that user source had no defined names. Once I switched the logging to only do usernames I found the info I expected.

Update:  
After running this on a Gateway which has defined names for users I got al of the expected values:

```auto
11:07:29.322 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - None None
11:07:29.322 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Auth Proj
11:07:29.322 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Auth ProjG
11:07:29.322 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Auth ProjGR
11:07:29.322 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Auth ProjGRY
11:07:29.323 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Auth ProjGY
11:07:29.323 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Auth ProjR
11:07:29.324 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Auth ProjRY
11:07:29.324 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Auth ProjY
11:07:29.324 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Hoban Washburn
11:07:29.324 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Inara Sera
11:07:29.324 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Jayne Cobb
11:07:29.324 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Kaylee Frye
11:07:29.324 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Malcolm Reynolds
11:07:29.324 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - None None
11:07:29.325 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - None None
11:07:29.325 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Shepard Book
11:07:29.325 [Browser Thread: 58637] INFO Perspective.Designer.Workspace - Zoe Washburn

```

You should inspect what user source the PROJECT defaults to if you are still not seeing any logging. Where are you running the code (Designer/Session/Script Console)?

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [October 26, 2021, 6:07pm UTC](https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358/3 "2021-10-26T18:07:49Z")

</div>

You are correct! So I am using the default user source and some of my users do not have names but they all have usernames so I used the script below:  
Still did not get any logs

```auto
	users = system.user.getUsers("")
	for user in users:
	    system.perspective.print(user.get('username'))

```

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 26, 2021, 6:19pm UTC](https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358/4 "2021-10-26T18:19:22Z")

</div>

Is there a difference in your environment between “default” and the default user source for the project? Verify that you are indeed using the correct identity provider by specifying the one you expect to see values in.

you could also improve the logging:

```auto
	users = system.user.getUsers("")
    system.perspective.print('Users found: {0}'.format(len(users)))
	for user in users:
	    system.perspective.print('User: {0}'.format(user.get('username')))

```

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [October 26, 2021, 6:35pm UTC](https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358/5 "2021-10-26T18:35:09Z")

</div>

So I’ve tried different user sources and identity providers.  
None of them works. I get this error:

Error fetching users.

I tried your script too and get the same error.

I am trying this script on a button; however, eventually, I would like to bind a table’s data to the user data I get from the script just like the vision component.

---

<div class="post-metadata">

**Author:** ![mcgheeiv](https://avatars.discourse-cdn.com/v4/letter/m/71c47a/32.png) [@mcgheeiv](https://forum.inductiveautomation.com/u/mcgheeiv)\
**Post date:** [October 26, 2021, 6:42pm UTC](https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358/6 "2021-10-26T18:42:34Z")

</div>

Have you checked out:

> **[Ignition Exchange](https://inductiveautomation.com/exchange/2128/overview)**
>
> Discover, share, and download community made Ignition resources in collaboration with your organization or the Ignition community.

There are also utilities for Roster and Schedule management.

---

<div class="post-metadata">

**Author:** ![cmallonee](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/cmallonee/32/6416_2.png) [@cmallonee](https://forum.inductiveautomation.com/u/cmallonee)\
**Post date:** [October 26, 2021, 6:51pm UTC](https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358/7 "2021-10-26T18:51:36Z")

</div>

> [@pkhoshroo](#):
>
> Error fetching users.

Ah, yes, that's my fault. I often mix-up User Sources and Identity Providers for no reason. I meant to ask if there was a difference between the "default" user source and the user source specified as the default for the project. You should only be supplying User Source names to the `getUsers` function, and you should not be seeing that error when you do so. If you are encountering that error while supplying a valid user source, then something else is going on.

> [@pkhoshroo](#):
>
> I tried your script too and get the same error.

My script should NOT be causing that error (though it IS missing a right paren). Please double-check.

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [October 26, 2021, 7:21pm UTC](https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358/8 "2021-10-26T19:21:02Z")

</div>

Thank you very much! I am going to check that again.

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [October 26, 2021, 7:21pm UTC](https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358/9 "2021-10-26T19:21:38Z")

</div>

Thank you very much. I just downloaded and imported the project and I am able to see its script.

---

<div class="post-metadata">

**Author:** ![EWiehman](https://avatars.discourse-cdn.com/v4/letter/e/50afbb/32.png) [@EWiehman](https://forum.inductiveautomation.com/u/EWiehman)\
**Post date:** [January 27, 2023, 12:52pm UTC](https://forum.inductiveautomation.com/t/get-the-list-of-all-users-in-perspective/52358/10 "2023-01-27T12:52:35Z")

</div>

Thank you this is amazing. You can change the table selection style and add "borderStyle:none" to perhaps improve the look on the cell selection. Perhaps that's just preference.
