You're on your way to the next level! Join the Kudos program to earn points and save your progress.
Level 1: Seed
25 / 150 points
Next: Root
1 badge earned
Challenges come and go, but your rewards stay with you. Do more to earn more!
What goes around comes around! Share the love by gifting kudos to your peers.
Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!
Join now to unlock these features and more
I want to show the project admin role users in project summary page, though i have written the custom script to show the users under role: projet admin. However, there is a dependency to pass the "issue key" manually to get the users under role "10050" for that perticualler project . Though i dont want to pass the "issue key", it should dynamically get the "project key" from the project summary page. Here is my example code:
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager
import com.atlassian.jira.user.ApplicationUsers
import com.onresolve.scriptrunner.runner.rest.common.CustomEndpointDelegate
import groovy.transform.BaseScript
import com.atlassian.jira.bc.projectroles.DefaultProjectRoleService
import javax.ws.rs.core.MediaType
import javax.ws.rs.core.MultivaluedMap
import javax.ws.rs.core.Response
import com.atlassian.jira.issue.Issue
import org.apache.log4j.Logger
@BaseScript CustomEndpointDelegate delegate
ProjectAdmins() { MultivaluedMap queryParams ->
// get a reference to the current page...
// def page = getPage(queryParams)
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)
long projectRoleId = 10050 // ID of Automatic Watcher project role
def role = projectRoleManager.getProjectRole(projectRoleId)
def issue1 = ComponentAccessor.getIssueManager().getIssueByCurrentKey("INT-1")
def actors = projectRoleManager.getProjectRoleActors(role, issue1.getProjectObject())
def usersInRole = actors.getApplicationUsers();
def projectRoleUsers = new StringBuffer()
for (g in usersInRole) {
projectRoleUsers.append(g.getName()+",")
projectRoleUsers.append("<br>")
}
def dlgHeader = """<div>
<b><u>Project Admins</u></b>
</div>"""
def dialog =
"""<section role="dialog" id="sr-dialog" class="aui-layer aui-dialog2 aui-dialog2-medium" aria-hidden="true" data-aui-remove-on-hide="true">
<header class="aui-dialog2-header">
<h2 class="aui-dialog2-header-main"><b>Project Admin User List</b></h2>
<a class="aui-dialog2-header-close">
<span class="aui-icon aui-icon-small aui-iconfont-close-dialog"><b>Close</b></span>
</a>
</header>
<div class="aui-dialog2-content">
""" + dlgHeader + """
""" + projectRoleUsers + """
</div>
</section>
"""
Response.ok().type(MediaType.TEXT_HTML).entity(dialog.toString()).build()
}