Retrieve Full Name from an Actors Project Role

I need to retrieve an project Actors Full Name (i.e Bob Smith), when iterating over project roles.

Currently I am able to use:

//Gets all of the projects, along with project roles (i.e. "developer" + username and full name, i.e. bed2scp Daniel Burke ENGIT_Developer)
for(Project projectarray in projectArray){
for(ProjectRole projectrole in projectRoles){
def actorRole = projectRoleManager.getProjectRoleActors(projectrole, projectarray)
//projectLead = projectarray.getProjectLead()

if(actorRole.getUsers().toArray().size() >= 1){
log.error("\r\n" + projectarray.getKey() + "_" + projectrole.getName() + "=" + actorRole.getUsers().toArray() + "" + "\n" + "\r\n")

However, this only retrieves the users username i.e. bed2scp 

Ideally I would like to have both like: bed2scp Daniel Burke 

I tried to use:

//Gets all of the projects, along with project roles (i.e. "developer" + username and full name, i.e. bed2scp Daniel Burke ENGIT_Developer)
for(Project projectarray in projectArray){
for(ProjectRole projectrole in projectRoles){
def actorRole = projectRoleManager.getProjectRoleActors(projectrole, projectarray)
//projectLead = projectarray.getProjectLead()

if(actorRole.getUsers().toArray().size() >= 1){
log.error("\r\n" + projectarray.getKey() + "_" + projectrole.getName() + "=" + actorRole.getUsers().toArray() + actorRole.getDisplayName() + "" + "\n" + "\r\n")

But this method is not valid.

 

Please help!

1 answer

1 accepted

1 vote
Jenna Davis Community Champion Jan 19, 2018

Hello, 

getUsers is returning a set of ApplicationUsers. You need to go through that set and get the display name for each user. Something like this should work to get them:

def userNames = actorRole.getUsers()
def displayNames = userNames.each {it.displayName}

Let me know if this helps or if you have any other questions. :)
Jenna

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published yesterday in Hipchat

Moving from Hipchat to Stride? Here’s what you’ll love

Heya, Hipchat friends! We’re so happy you’re checking out   Stride. Whether you know it or not, you have been instrumental in making Stride come to life. Every feature, design, and functionality...

75 views 2 6
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you