Our new Appfire Documentation Space is now live!
Take a look here! If you have any questions please email support@appfire.com
Assign the related issues of the current issue to users in a Project role in Round Robin method
Abstract
This code snippet assigns the related issues of the current issue to users of a project role in a round-robin method.
Logic
Access the users of a project role and run a loop on the related issues of the current issue to set the assignee of each related issue to the users of project role in a round-robin method
Snippet
def roleName = <projectRoleName>
def projectRoleManager = getComponent(com.atlassian.jira.security.roles.ProjectRoleManager)
def projectRole = projectRoleManager.getProjectRole(roleName)
def users = projectRoleManager.getProjectRoleActors(projectRole, issue.projectObject)
.applicationUsers
.toSorted { it.key }
if (!users) {
return null
}
// Assign the issue in Round robin method
def index = users.size()
issue.<linkedIssues>.each{
index = index - 1
it.setFieldValue("assignee",users[index])
if (index == 0){
index = users.size()
}
}
Placeholders
Placeholder | Description | Example |
---|---|---|
| Name of the project role name |
|
| Link to the linked issues |
|
Examples
The output of this code snippet is void. This you could use in:
A Groovy expression, for example to:
Set the assignee of the issues that block the current issue to the users of the QA project role using the Scripted Groovy Operation issue
def roleName = "QA" def projectRoleManager = getComponent(com.atlassian.jira.security.roles.ProjectRoleManager) def projectRole = projectRoleManager.getProjectRole(roleName) def users = projectRoleManager.getProjectRoleActors(projectRole, issue.projectObject) .applicationUsers .toSorted { it.key } if (!users) { log.info "No users for project role $roleName" return } // Round robin def index = users.size() issue.getLinkedIssues("is blocked by").each{ index = index - 1 it.setFieldValue("assignee",users[index]) if (index == 0){ index = users.size() } }
Set the assignee of the subtasks of the current issue to the users of the Developers project role using the Scripted Groovy Operation issue
def roleName = "Developers" def projectRoleManager = getComponent(com.atlassian.jira.security.roles.ProjectRoleManager) def projectRole = projectRoleManager.getProjectRole(roleName) def users = projectRoleManager.getProjectRoleActors(projectRole, issue.projectObject) .applicationUsers .toSorted { it.key } if (!users) { log.info "No users for project role $roleName" return } // Round robin def index = users.size() issue.subtasks.each{ index = index - 1 it.setFieldValue("assignee",users[index]) if (index == 0){ index = users.size() } }