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

Next challenges

Recent achievements

  • Global
  • Personal


  • Give kudos
  • Received
  • Given


  • 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 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

// 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)
.toSorted { it.key }

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

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

if (!lastIssueIdWithAssignee) {

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


0 answers

Suggest an answer

Log in or Sign up to answer
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