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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Get issue id of last created issue of a certain issue type


Hi all,

One of the dev teams that I work with at my job want to utilize round robin assignment of users for a certain issue type. We have 4 listed users under the project role, "Workers", and for every Story issue that gets created in the project, the 4 users (person A [bmorris], person B [kbaker], person C [mkim], and person D [mlubag]) should be assigned in sequential order via round robin. Since the list of users is sorted by user key, the assignment goes from person A -> person D and again in that order infinitely.

In reference to this groovy script from Adaptavist Library (, I was able to use this script and render its use for our purpose by changing the value for final roleName to 'Workers':


import com.atlassian.jira.component.ComponentAccessor

// The role you want assignees to set from
final roleName = 'Workers'

// If it is true, the assigned issues will be reassigned
final reassignedIssues = true

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")

if (!reassignedIssues && issue.assignee) { ('The issue is already assigned')

// 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()]



This almost works the way I want it, but there's one problem...In the part of the script that pulls the most recently created issue that has an assignee: 

def lastIssueIdWithAssignee = issueManager.getIssueIdsForProject(
.find { issueManager.getIssueObject(it).assignee }

if (!lastIssueIdWithAssignee) {

This code seems to pull the most recently created issue, regardless of the issue type and whether or not it's assigned to anyone. We only want the round robin script to focus on issues of the issue type Story.

Is there a way in Groovy to get the most recently created issue (of a certain issue type) in a project?

P.S. I have this set as a post-function for the Create transition in a workflow specifically set for the Story issue type. I thought that would be enough, but it still looks at all the issues in the project, and not just stories.

Any help would be highly appreciated.

Thanks all!

-Ian Balas

1 answer

1 accepted

0 votes
Answer accepted

As per repost:


I had to make the following changes to the script:

def lastIssueIdWithAssignee = issueManager.getIssueIdsForProject(
.find {issue.getAsString("issuetype") == "Certification" }

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events