How to get list of Linked issues which are "is blocked by" current and ranked higher in backlog?

Mikhail Kurskiy April 18, 2018

Hi Team,
I want to check my backlog through the scripted field looks like default field on scrum board "Linked issues". But I need to enumerate only those ones that are linked to current by "is blocked by" link and ranked higher in backlog and not in statuses Done or Won't fix.
Thanks for help.
2018-04-19_08-50-08.png

3 answers

1 accepted

0 votes
Answer accepted
Mikhail Kurskiy April 19, 2018

Solved! :)

import com.atlassian.jira.component.ComponentAccessor

//Get necessary managers
def cfm = ComponentAccessor.customFieldManager
def linkManager = ComponentAccessor.issueLinkManager

def rank = cfm.getCustomFieldObjectByName("Rank")
def issueRankValue = (String) issue.getCustomFieldValue(rank)
def issueProject = issue.getProjectId()

def issueKeys = []
//Go through all linked issues and collect their keys
linkManager.getOutwardLinks(issue.id).each{
def linkedIssue = it.destinationObject
def linkedIssueProject = linkedIssue.getProjectId()
def linkType = it.getIssueLinkType()
def linkedIssueRankValue = (String) linkedIssue.getCustomFieldValue(rank)
def linkedIssueStatus = linkedIssue.getStatus()
def linkedIssueStatusName = linkedIssueStatus.getName()

if( issueProject == linkedIssueProject &&
linkType.getInward() == "is blocked by" &&
issueRankValue > linkedIssueRankValue &&
!(linkedIssueStatusName in ["Done", "Won't fix", "Not Reproduced"]) )
{
issueKeys.add("${linkedIssue.key}")
}
}

if(issueKeys.size() > 0)
{
return issueKeys.join(', ')
}
else
{
return null
}
0 votes
Steve Revill January 20, 2021

We have this issue, where we're using one epic to demarcate between the ones we care about and the stuff that's "below the line" (e.g. still being refined) and all of the epics are ordered by rank.

This answer doesn't give us a dynamic way to achieve this, but if your magic ticket is fixed, then it should do the job. Let's assume this magic epic is "MG-123". If search in Jira, any search, then replace the JQL with "key = MG-123", then you should get a table of results with one result in it. Add a column to display the "rank" field. You'll get the crazy rank text.

Now, in the JQL search you actually wanted in the first place, your JQL needs to include "rank < 'gibberish'" to only show the stuff above the line or > for the stuff below the line. Something like that.

Steve Revill January 20, 2021

Apologies - I was led here from How-I-can-I-use-JQL-to-show-all-issues-with-a-rank-higher-than-a-particular-issue and didn't spot the question is different, so my answer is for that question (which has been closed without answer after seven years - thanks Atlassian!)

0 votes
Mikhail Kurskiy April 19, 2018

It looks like frequently used functionality. But I didn't find answer during several days.
Any other ideas? - add-ons, gadgets?

Suggest an answer

Log in or Sign up to answer