Show latest Fix Version/s from linked issues in scripted field

Tobias Albrecht March 8, 2017

Hi,

I would like to do the following:

Let's say I have 2 Issues linked to an epic. Each of those may have in Fix Version/s and entry like:

Issue1 : Fix Version/s: SW15.08, SW15.12

Issue2 : Fix Version/s: SW15.10

Now I would like to show in a scripted field (LatestFixVersion) on epic level the latest Fix Version/s entry in this case SW15.12.

Thanks for you support

Tobias

2 answers

1 vote
Thanos Batagiannis _Adaptavist_
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.
March 8, 2017

HI Tobias, 

You can try something like 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comparator.VersionComparator
import com.atlassian.jira.project.version.Version

def issue = issue as Issue

def fixVersionsInIssues = [] as List<Version>
def comparator = new VersionComparator()

ComponentAccessor.getIssueLinkManager().
    getOutwardLinks(issue.id)?.
    findAll {it.issueLinkType.name == "Epic-Story Link"}?.
    each {it -> fixVersionsInIssues.addAll(it.destinationObject?.fixVersions) }

fixVersionsInIssues?.max(comparator)?.name

The VersionComparator actually compares the versions against their sequence.

Hope that helps, 

regards, Thanos

Lacey McDonnell July 11, 2017

Hi, Thanos... Me again!

 

I tried using this for my own purposes but it's throwing an error on the "-&gt" as unexpected character "-"

Tried with different Templates but got the same results.

 

startupfail.PNG

Tobias Albrecht July 11, 2017

Hi Lacey,

I think you should correct the greater than symbol here like such:

12-07-2017 08-11-19.jpg

 

regards Tobias

Lacey McDonnell July 12, 2017

I caught that after posting :) So silly of me. However, even with correcting that as well as the Versions slanted brackets, it's still not operational :( I opened a separate question for it on Community.

0 votes
Tobias Albrecht March 8, 2017

Hi Thanos,

thanks a lot for your quick response, it works  smile

One more thing: I'm using different issuetypes (SC1Feature,SC2Feature) linked to the epic.

How could I select only the max fixversion of all the issues of just a certain issuetype e.g. just SC1Feature?

Thanks for feedback

regards

Tobias

Thanos Batagiannis _Adaptavist_
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.
March 8, 2017

Hi Tobias,

In the above script edit it to include a condition for the issue type. 

ComponentAccessor.getIssueLinkManager().
    getOutwardLinks(issue.id)?.
    findAll {it.issueLinkType.name == "Epic-Story Link" && it.destinationObject.issueType.name == "Bug"}?.
    each {it -> fixVersionsInIssues.addAll(it.destinationObject?.fixVersions) }

regards, Thanos

Tobias Albrecht March 9, 2017

Hi Thanos,

thanks I tried it with the "it.destinationObject.issueType.name == "Bug" but it seems that this expression is deprecated since v4.0 and instead of this Issue.getIssueTypeObject() shall be used .

so I tried it like this but did not work. Did I miss something here?

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comparator.VersionComparator
import com.atlassian.jira.project.version.Version
 
def issue = issue as Issue
 
def fixVersionsInIssues = [] as List<Version>
def comparator = new VersionComparator()
 
ComponentAccessor.getIssueLinkManager().
    getOutwardLinks(issue.id)?.
 findAll {it.issueLinkType.name == "Epic-Story Link" && issue.issueTypeObject.name == "Bug"}?. 
    each {it -> fixVersionsInIssues.addAll(it.destinationObject?.fixVersions) }
 
fixVersionsInIssues?.max(comparator)?.name

 

Thanks again for your quick response

regards

Tobias

Thanos Batagiannis _Adaptavist_
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.
March 9, 2017

try 

it.destinationObject.issueTypeObject.name == "Bug"

where 'Bug' is the issue type you want to check (SC1Feature)

Tobias Albrecht March 9, 2017

Great ! that works

Thanks a lot

regards

Tobias

Suggest an answer

Log in or Sign up to answer