Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to change in list ?

Lola December 22, 2021
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
AUG Leaders

Atlassian Community Events