Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to change in list ?

Hello,

I am trying to get all the administrators of the projects but I would like to get this in the table. There are several admins per project so I would like to make a table in which there would be several tables each covering the admins of each project

It is possible ?

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.bc.projectroles.ProjectRoleService;
import com.atlassian.jira.security.roles.ProjectRoleManager;
import com.atlassian.jira.project.Project;
import com.atlassian.jira.project.ProjectManager;
import com.atlassian.jira.security.roles.ProjectRole;
import com.atlassian.jira.security.roles.ProjectRoleActors;
import com.atlassian.jira.util.ErrorCollection;
import com.atlassian.jira.util.SimpleErrorCollection;
import com.atlassian.jira.user.util.Users
def sb = new StringBuffer()
ProjectRoleService projectRoleService = (ProjectRoleService) ComponentAccessor.getComponentOfType(ProjectRoleService.class);
ProjectRoleManager projectRoleManager = (ProjectRoleManager) ComponentAccessor.getComponentOfType(ProjectRoleManager.class);
ProjectManager projectManager = ComponentAccessor.getProjectManager();
ProjectRole administrator = projectRoleManager.getProjectRole("Administrators");
ErrorCollection ec = new SimpleErrorCollection();
//get all projects
projectManager.getProjectObjects().each{

//get all project admins for that project
ProjectRoleActors existingActors = projectRoleService.getProjectRoleActors(administrator,it,ec);
if (existingActors != null){
//get list of user names
Set<Users> users = existingActors.getUsers();
users.each { user->
sb.append(user.getName() + ', ')
}
}
sb.append("\n")
}
return sb.toString()

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you