It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

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
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

863 views 7 0
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you