Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Retrieve Full Name from an Actors Project Role

Daniel Burke January 18, 2018

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

Suggest an answer

Log in or Sign up to answer
2 votes
Answer accepted
Jenna Davis
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 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

Bhagyashree Karale May 14, 2022

Hey @Jenna Davis I want to do the same but with rest apis. can you help?

Bhagyashree Karale May 14, 2022

I actually have to validate all data after migration. so basically my aim is to identify the lost data during migration using rest api and python

TAGS
AUG Leaders

Atlassian Community Events