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

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

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

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

Hi Lacey,

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

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

 

regards Tobias

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.

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

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

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

try 

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

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

Great ! that works

Thanks a lot

regards

Tobias

Suggest an answer

Log in or Join to answer
Community showcase
Teodora [Botron]
Published Thursday in Marketplace Apps

Jira Inferno: The Nine Circles of Jira Administration Hell

If you spend enough time as a Jira admin - whether you are managing a single, mid-sized instance, a large enterprise one or juggling multiple instances at once - you will eventually find yourself in ...

302 views 0 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot