How to set "Linked Issues" as mandatory field on issue creation?

Hi there!

My goal is to force users to link the newly created issue with the existing one (parent - child hierarchy). To ensure this, I set the "Linked Issues" field as required in the Field configuration. But this is obviously not enough because it doesn't work as expected.

Let me explain:

  • First line - The relation type is chosen ("is Child of" is selected as default)
  • Second line - Related issue is not selected - this field stays empty


Despite the fact, that the second line is empty, the issue will be created - as a result, no issue link is generated. This is undesirable behavior. Only the relation type filling is checked. JIRA unfortunately does not check if the second line is filled in.

Do you guys have any ideas how to achieve the desired functionality? How to force the users to fill in also the related issue - the second line?

Thanks for your time!

4 answers

1 accepted

2 votes
Accepted answer

I'm on a similar quest, but I only have half the answer for my goal.  However this may help you with some tweaking or no tweaking.

I am on a quest to fix users that would not link issue when resolving issues as duplicate.

I found the following snippet code that will force users to fill in the "empty" space in issue links

request = webwork.action.ActionContext.getRequest()

if (request){
// check for new duplicates link
linktype = request.getParameter('issuelinks-linktype')
linkedIssue = request.getParameter('issuelinks-issues') 

Thank you Randy. This is exactly what I was looking for!

Hi there,

sooo I created this script. It should provide the functionality.

You can also set which link type is required and which issue types are allowed.

import com.atlassian.jira.ComponentManager;
import com.atlassian.jira.issue.IssueManager;
import com.atlassian.jira.issue.MutableIssue;

String paramRequiredLinkType = "relates to";
List paramRequiredIssueTypes = Arrays.asList("Bug", "New Feature");

def request = webwork.action.ActionContext.getRequest();
if (request) {
    String linkType = request.getParameter('issuelinks-linktype');
    String[] linkedIssues = request.getParameterValues('issuelinks-issues');
    if (linkType != null && linkType.equals(paramRequiredLinkType) && linkedIssues != null) {
        if (linkedIssues.size() > 0) {
            IssueManager myIssueManager = ComponentManager.getInstance().getIssueManager();
            for (String tmpLinkedIssue: linkedIssues) {
                MutableIssue toBeLinkedIssue = myIssueManager.getIssueObject(tmpLinkedIssue);
                if (toBeLinkedIssue != null) {
                    if (!paramRequiredIssueTypes.contains( {
                        return false;
                } else {
                    return false;
            return true;
return false;

Super. Thanks!

Hi, I have the same requirement.
however, the line
IssueManager myIssueManager = ComponentManager.getInstance().getIssueManager();
now doesn't work on the newest version of JIRA stating that it is deprecated and method getIssueManager cannot be found in ComponentManager. Please advise what is the alternative code that can be used?

Hi, should use the ComponentAccessor instead the ComponentManager. It means that you should replace the following lines:

import com.atlassian.jira.ComponentManager;
IssueManager myIssueManager = ComponentManager.getInstance().getIssueManager();

with these lines:

import com.atlassian.jira.component.ComponentAccessor;
def myIssueManager = ComponentAccessor.getIssueManager();


Thanks heaps to you Samuel.

The line in question works now.

However, I see warning with regards to 'IssueTypes' indicating deprecated function call for the line

if (!paramRequiredIssueTypes.contains( 

on the latest version of JIRA. Hence, the script is not executing.

Please advise how it could be changed to.


yes, sometimes with the JIRA updgrade some of the methods become obsolete/deprecated. In such cases it is necessary to go through the API documentation and find appropriate methods. Usually, there is a note that the method is deprecated and there is also a link to the replacement.

Regarding the line you mentioned, please try this:

if (!paramRequiredIssueTypes.contains(toBeLinkedIssue.getIssueType().getName())) {



Thank you Samuel.

I executed the full script. It runs well, but doesn't behave as expected in the title of this query. Please advise if you have a full working script?

The requirement is to create a Spike issue type, with mandatory 'relates to' to a 'Bug' or 'Epic'.

Need a Validator script for the same on latest JIRA.

Thank you

0 votes

Links are not fields, they're relationships between issues, which makes it a bit harder than just flagging a field (in fact, the field you've tried to flag is ephemeral - it's populated by duplicating the link information into it when there are links, and the data you enter into it is used to create links, and then its discarded.  The field doesn't actually exist in the database)

The best you can do here is to add a validator to the create transition - one that checks that at least one link is defined.  It will not be able to highlight the links field as mandatory on the create screen, and it only kicks in when the user clicks "create" - a well written validator will return them back to the screen and have a good message to tell them what they've missed.

There are several validators in the marketplace (mostly as part of bigger addons), or, as ever, you can always do this with the script runner (maximum flexibility there, but you'll need to do a little bit of coding)

Hello Nic, thanks for your reply. I tried to use Script runner but I was unsuccessful. Here's why: - I have added Custom script validator on CREATE transition - Snippet of condition in validator: return issueLinkManager.getOutwardLinks(issue.getId())*'Hierarchy') - I THINK that the condition is checking for already existing links. But on the Create the link hasn't been already created. So JIRA has nothing to return. I understand that this condition will work on subsequent transitions but not on the Create - please correct me if I am wrong. Do I have any other options?

I have also tried "getInwardLinks(...)" with no result.

A validator should return "true" for "passed validation" or "false" (and ideally, an exception message) if validation fails. The validator is passed the current issue object that the system is *going* to create, so the links should be available on it, but you'll need to check for both inward and outward links (and I'm not sure what the line of code you've posted is really trying to do)

I tried to use (k) SIL Validator (JJupin Add-on) but with no result. Code: string[] linkedIssuesHierarchy = linkedIssues(key, "Hierarchy", 0); // checks both inwards and outwards links if (size(linkedIssuesHierarchy) > 0) { return true; } else { return false; } Result was only error message: Exception occurred: com.atlassian.jira.util.dbc.Assertions$NullArgumentException: issue should not be null! I think that JJupin issue "key" variable resolution does not work on Create transition. As far as I know, If a transition's validator FAILS, the transition's post functions will NOT be executed. On Create transition there are post-functions for issue creation. So I think issue does not exists (maybe only some kind of object that you have noted) in this step so clearly this issue cannot be linked to real existing JIRA issues.

I have also tried the method hasInput of JJupin add-on (however it is documented only for custom fields) Code: if (hasInput("issuelinks")) { return true, "issuelinks-issues", "test OK"; } else { return false, "issuelinks-issues", "test FALSE"; } But again, no result... this condition was always true no matter if I filled in also linked issues field or only the link type. I tried to replace "issuelinks" with "issuelinks-issues" but this condition was always false.

Anybody? Is this even possible to achieve?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,946 views 19 22
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