JIRA - How to filter the list of link of linked issue according to issuetype ?

Rambo July 4, 2016

Hello everybody


Context : My project has 3 issuetypes : "One", "Two" and "Three". Each "One" is linked with one or more "Two". And each "Two" is linked to one or more "Three". I use the field "issue linked" to link this issues in a creation issue screen.
Problem : When the field appears on the create issue screen, it gives you a list of all issue links ("duplicate", "blocks", "relate to"... And those I create). I want this list shows only the links which is concerned by the issuetype I choose.
Ex : If I choose issuetype "Two", I want to select only the value "relate to One" and "relate to Three" (and not "relate to Two" or "duplicate"...)

What I want to avoid : User can't make mistake on the field "issue linked" when he chooses an issue type.

What I'm trying : Write a javascript in the "issue linked" description which can filter the list of links according to the issue type I choose. But i don't realy know what kind of code should I write...

I hope I have been clear. Thanks for your help.

 

Note: I want to avoid the plugin "Structure".

1 answer

1 vote
Rambo July 6, 2016

I'm trying another way...

Using Behaviours : I create a Beaviours on my 'issue link' field. And with a groovy script, I'd like to auto fill the value of 'issue link' type (related to One) and the let the user choose  th issue he wants to link.

It work with 'component' : With this method, I managed to auto fill the field 'component' when the issue type is changing.
Here is the code I used ("Two" is my component):

import com.atlassian.jira.component.ComponentAccessor

import static com.atlassian.jira.issue.IssueFieldConstants.*

// set Components
def projectComponentManager = ComponentAccessor.getProjectComponentManager()
def components = projectComponentManager.findAllForProject(issueContext.projectObject.id) 
getFieldById(COMPONENTS).setFormValue(components.findAll { it.name in ["Two"] }*.id)

What I want : I'd like to know what I have to change in this script to have the same effect on the 'issue link'.

Thans for your help, I know it's not an easy question.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events