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 Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

147 views 1 17
Join discussion

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