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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Auto assign created issues to users if unassigned for more than 24 hours based on Component Edited

Hi all,

One of the tech leads at my job is looking to have issues in her project automatically assigned to users in rotation if left unassigned for over 24 hours. This is also to be dependent on the Component/s that the issue is listed as part of since her users support various systems/components.

I'm not the most experienced with coding, but did find this script from Scriptrunner https://library.adaptavist.com/entity/round-robin-assign-issue-to-users-in-a-certain-project-role and figured this may be near what I'm trying to accomplish. (script pasted below)

The script in the link assigns issues to users specific to a project role in round robin. This is almost what I'm looking for, except I want to set assignees based on the components listed on the issue rather than the project role listed.

What I'm thinking of doing is replacing the roleName variable with an string array of components listed for this project, and then maybe using a jqlQuery to pull a list of users that have ever been assigned to issues with said components listed, pass this list as a string array, and then use a random number constructor to randomly pick a number in that array of listed users, and with whatever number is picked, assign that user to the issue.

Now the challenge for me is to translate this into code (if even possible).

I shall post a snippet of the changes I'll be making to this, but I wanted to throw this into the Community to see if anyone had any suggestions or possibly a solution to this that may work better than what I've proposed. I'm open to anything at this point.

Thanks in advance!

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.security.roles.ProjectRoleManager

// the role you want assignees to set from
final String roleName = "Project Role"

def issueManager = ComponentAccessor.issueManager
def projectRoleManager = ComponentAccessor.getComponent(ProjectRoleManager)

// get all of the users associated with the specified project role
def projectRole = projectRoleManager.getProjectRole(roleName)

// sort the users of the project role using the user key
def users = projectRoleManager.getProjectRoleActors(projectRole, issue.projectObject)
.applicationUsers
.toSorted { it.key }

// there are no users in the specific project role
if (!users) {
log.info "No users for project role $roleName"
return
}

// find the latest created issue id that has an assignee
def lastIssueIdWithAssignee = issueManager.getIssueIdsForProject(issue.projectObject.id)
.sort()
.reverse()
.find { issueManager.getIssueObject(it).assignee }

if (!lastIssueIdWithAssignee) {
issue.setAssignee(users.first())
return
}

def lastAssignee = issueManager.getIssueObject(lastIssueIdWithAssignee).assignee
def lastAssigneeIndex = users.indexOf(lastAssignee)
def nextAssignee = users[(lastAssigneeIndex + 1) % users.size()]

issue.setAssignee(nextAssignee)

0 answers

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Marketplace Apps & Integrations

New Cloud Apps Roundup - Spring 2021

Atlassian's marketplace partners have had a very productive start to 2021! Since our last roundup, our developer community has added over 160 new cloud apps to the Atlassian Marketplace to help you...

139 views 3 16
Read article

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