# \[Bug-1747\]Perspective and system.user.getRoles("") user source not found

**URL:** <https://forum.inductiveautomation.com/t/bug-1747-perspective-and-system-user-getroles-user-source-not-found/42989>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [February 3, 2021, 10:11pm UTC](https://forum.inductiveautomation.com/t/bug-1747-perspective-and-system-user-getroles-user-source-not-found/42989 "2021-02-03T22:11:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 3, 2021, 10:11pm UTC](https://forum.inductiveautomation.com/t/bug-1747-perspective-and-system-user-getroles-user-source-not-found/42989/1 "2021-02-03T22:11:05Z")

</div>

In the startup script for a _Perspective_ popup I have

```auto
def runAction(self):
    roles = system.user.getRoles("")
    ...

```

and it results in the following error when applying the script

```auto
File "<function:runAction>", line 31, in runAction
java.lang.IllegalArgumentException: java.lang.IllegalArgumentException: 
    User Source "" not found.

```

Any idea what's wrong with this? The manual states

> - Scope: Gateway, Vision Client, Perspective Session

If anyone cares, I'm creating a popup with a flex repeater with a checkbox per role to allow selection of which roles have access to each password in my database.

---

<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:** [February 3, 2021, 10:22pm UTC](https://forum.inductiveautomation.com/t/bug-1747-perspective-and-system-user-getroles-user-source-not-found/42989/2 "2021-02-03T22:22:17Z")

</div>

Did you configure a user source for the project?  
In the Designer’s menu: `Project > Project Properties > General > User Source`  
If that has not been set, then you can’t request any information about users because you’ve not specified where to look.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 3, 2021, 10:42pm UTC](https://forum.inductiveautomation.com/t/bug-1747-perspective-and-system-user-getroles-user-source-not-found/42989/3 "2021-02-03T22:42:39Z")

</div>

Yes. I’m using an AD hybrid user source and the script works in the Script Console.

```auto
import json
instances = []
roles = system.user.getRoles("")
print roles
c = 0
for role in roles:
	instance = {}
	instance['caption'] = role
	instance['checked'] = False
	instances.append(instance)
print(json.dumps(instances, indent = 4))

```

Thanks.

Oh, and the error shows up when I’m hitting the OK / Apply buttons. I haven’t even had the joy of trying to run it.

---

<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:** [February 3, 2021, 10:56pm UTC](https://forum.inductiveautomation.com/t/bug-1747-perspective-and-system-user-getroles-user-source-not-found/42989/4 "2021-02-03T22:56:48Z")

</div>

I think there’s a disconnect between running it in the console and running it in a Perspective session. That being said, you’re right it’s not working. _That_ being said, you don’t need this function in a Perspective context anyway:

```auto
roles = self.session.props.auth.user.roles

```

Update: Ignore that last part. I thought you were trying to get the roles of a user, but it looks like you’re trying to get all of the roles for the User Source.

Current Workaround:  
You need to supply the name of the default User Source for the project.

I’ve opened an internal ticket to address the issue.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [February 3, 2021, 11:21pm UTC](https://forum.inductiveautomation.com/t/bug-1747-perspective-and-system-user-getroles-user-source-not-found/42989/5 "2021-02-03T23:21:15Z")

</div>

So I’m not bonkers. That’s a relief.  
Thanks for the fix. It’s working now

```auto
def runAction(self):
    roles = system.user.getRoles("AD internal hybrid")

```

.
