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

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

Change issue Rank using scriptrunner Edited

Hello everyone!

How its possible in Jira 8 get and modify issue Rank?

I found old solution 

but seems it is no longer actual.

Any ideas how to use Rank service in scriptrunner?


I find how to get Rank, but if i wanna to change rank of issue (like JIRA-1 is now RankHigher than JIRA-2)


import com.atlassian.jira.component.ComponentAccessor
def admin = ComponentAccessor.getUserManager().getUserByKey('admin')
def issueManager = ComponentAccessor.getIssueManager()
def issue1 = issueManager.getIssueByCurrentKey("JIRA-1")
def issue2 = issueManager.getIssueByCurrentKey("JIRA-2")
def rank = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(10700)
def rank_value1 = issue1.getCustomFieldValue(rank).toString()
def rank_value2 = issue2.getCustomFieldValue(rank).toString()


1 answer

1 accepted

0 votes
Answer accepted

Hello. If I'm not mistaken JiraAgile plugin ranks the issues, so you need use its classes and in particular com.atlassian.greenhopper.api.rank.RankService. Try this to make rank of issue1 after issue2:

import com.atlassian.greenhopper.api.rank.RankService
import com.atlassian.jira.issue.fields.CustomField
import com.onresolve.scriptrunner.runner.customisers.WithPlugin
import com.onresolve.scriptrunner.runner.customisers.JiraAgileBean
import com.atlassian.jira.component.ComponentAccessor


RankService rankService

def user = ComponentAccessor.getUserManager().getUserByKey('userName')
def issue1 = ComponentAccessor.getIssueManager().getIssueByCurrentKey("KEY")
def issue2 = ComponentAccessor.getIssueManager().getIssueByCurrentKey("KEY")
def rank = ComponentAccessor.getCustomFieldManager().getCustomFieldObject(rankFieldId)

rankService.rankAfter(user, rankFieldId, issue1, issue2)


Suggest an answer

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

5 mobile apps for Jira Cloud to boost productivity

  It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...

249 views 2 5
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