How to prevent epic linking issues to epics of a particular status

Jon November 9, 2018

our epics have open and closed status. we link the issues to the epic but we would want to make a condition so issues could not be linked to epics that are in the closed status. 

 

any ideas to pull this off? 

2 answers

0 votes
David W. March 21, 2019

@Jondo you mean the "closed" workflow status or the "closed" epic status?

The important status is the epic status. Closed epics are filtered from the "epic link" list by default. See this comment on how to close an epic.

However, users would still be able to see closed epics in the "epic link" list by clicking the "show done epics" checkbox and then they would also be able to associate an issue with done epics.

Kind regards,
David

Jon March 21, 2019

hi david, if I understand correctly its would be an epic that is in a status we made named closed (and actually this closed status we made is still worked one but we call it closed nonetheless) . (not a jira system closed). I can close the epic no problem but what we are trying to do is prevent the normal issues from being linked to the epics that are in the closed status. 

David W. March 21, 2019

Hi Jon,

okay, I understand, so you have a closed workflow status.

Well unfortunately there is no way to completely prevent linking issues to closed epics (not even with closed epic status).

All you can do is by default filter closed epics (closed epic status) from the "epic link" list as I commented above. But it seems that's not what you are looking for.

Unfortunately I also don't know of any plugin that could help you with your requirement.

Kind regards,
David

David W. March 25, 2019

Hi Jon,

I don't know if this is an option for you but there seems to be a possibility to do what you are looking for using ScriptRunner for Jira (non-free Jira plugin).

I haven't tried this myself but this is what a support employee of ScriptRunner's vendor told me (just replace Done with the name of the desired status):

It is possible to define a behaviour which you can attach to the Epic Link field. This behaviour code can look up the status of the selected issue, and if the status is Done then setError on the Epic Link field which would then prevent the user submitting the issue until they choose a different Epic.

The Epic Link field returns a String value like this: "key:SSPA-30" which you can then remove the word "key:" from and use the remaining string with the issueManager.getIssueByCurrentKey(String key) method to get the issue object. Then you can get the status.name from that issue object to check if it equals "Done".

Hope this helps.

Kind regards,
David

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
March 25, 2019

Hi David,

Thank you for your response.

I can confirm that the approach that you have defined above will only work inside of ScriptRunner for Jira Server and will not work inside of ScriptRunner for Jira Cloud

The reason for this is due to the fact that the cloud version does not contain the same behaviors functionality as the server version, due to the restricted functionality and API's which Atlassian provide inside JIRA Cloud. 

This is because  Atlassian only provides a Rest API in Jira Cloud and not the same Java API that the server version contains.

You can see more detailed information on the differences between ScriptRunner for JIRA Cloud and ScriptRunner for JIRA Server inside of the documentation page located here.

This means that unfortunately, it is not possible to restrict linking epics inside of Jira Cloud like you can do inside of Jira Server due to the fact that Atlassian does not provide the same API's and functionality in the cloud version of Jira as they do inside of the server version of Jira.

Regards,

Kristian

Like Tibor Balázs likes this
Iro Karavasili November 12, 2020

Hello @David Waldhans I was searching a possible workaround on this issue and I just saw your comment here. Have you tried this behavior?

@Kristian Walker _Adaptavist_ could you help a little bit (with an example maybe) with the code of this behavior?

Kristian Walker _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 12, 2020

Hi Iro,

As mentioned above it is not possible to achieve this requirement inside of Jira Cloud as the API's to achieve this do not exist inside of Jira Cloud.

If you require to achieve this on Jira Server then you will need to create a post on here and tag this with Jira server so that someone familiar with Jira Server can advise on this.

Regards,

Kristian

Iro Karavasili November 12, 2020

Thank you @Kristian Walker _Adaptavist_  I'll do so.

Vanessa Conceição de Sousa July 2, 2021

Hi David Waldhans!

 

Did you got the script? I need this in my server instance :)

 

Thanks

David W. July 12, 2021

Hi @Vanessa Conceição de Sousa ,

sorry, but I never had to use this myself in the end, so I cannot help you out with a working script.

However, you can have a look at https://library.adaptavist.com and see if there are any example scripts you could build upon. Or you could just contact Adaptavist support and ask if they could help you out :).

Kind regards,
David

0 votes
Henrique Bittencourt
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
November 13, 2018

Hi Jon!

Unfortunately, there is no way to achieve this on-the-fly.

Please take a look into this community post.

The JMWE addon (Jira Misc Workflow Extensions) allows you to add a workflow validator which will do this, called "Linked Issues Status Validator".  They will still be able to select a closed Epic, however when they try to create the issue it will error saying the Epic is closed, and they will have to choose another.

Hope this helps.

Best Regards.

Suggest an answer

Log in or Sign up to answer