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 Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Thursday in Marketplace Apps

Tips on how to choose the best estimation method for your planning

Planning and grooming sessions all come with their own sets of rules. Team members meet to estimate stories or other work items, all according to an agreed-upon process. And with every session comes ...

65 views 0 11
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