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

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

Avatar

1 badge earned

Collect

Participate in fun challenges

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

Challenges
Coins

Gift kudos to your peers

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

Recognition
Ribbon

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!

Leaderboard

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
4,553,380
Community Members
 
Community Events
184
Community Groups

Change issue Rank using scriptrunner

Edited

Hello everyone!

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

I found old solution https://community.atlassian.com/t5/Jira-questions/Using-the-GreenHopper-API-to-modify-rank/qaq-p/245912 

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)
issue.getCustomFieldValue(rank)
def rank_value1 = issue1.getCustomFieldValue(rank).toString()
def rank_value2 = issue2.getCustomFieldValue(rank).toString()

Regards

1 answer

1 accepted

1 vote
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

@WithPlugin('com.pyxis.greenhopper.jira')

@JiraAgileBean
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)

 

padraik
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
Jun 20, 2022
import com.atlassian.greenhopper.api.rank.RankService

doesn't work for me.
"Unable to resolve class "com.atlassian.greenhopper.api.rank.RankService"

Does anyone have any suggestions?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.6.1
TAGS
AUG Leaders

Atlassian Community Events