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

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

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 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 ...

297 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