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

In the startup script for a Perspective popup I have

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

and it results in the following error when applying the script

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.

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.

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

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


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.

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:

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.

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

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


1 Like