It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Make "Issue Link" a required field is not being enforced

I set up a field configuration such that the "Issue Link" field is a required field for a specific type if issue. (What I'm trying to do is I created a "Test" type and I want to enforce that this issue type is linked to the Story(ies) it is testing).

I see that the drop down for Linked Issues is indeed requried. However the text field below it which lets you set the issue(s) is NOT required. There is always a default link type set, so in effect, you will have the Linked issue drop down type set (i.e. blocks, relates to etc), but it is not enforcing that you select an issue to link it to.

Is there a way to set both the Linked Issue drop down AND the issue field both to required? Or is there a way to check if that field is blank? There has to be a way to do that?

Thanks in advance.

4 answers

1 accepted

0 votes
Answer accepted

Please note the value of 'Tests' in the following is actually the Name of the link (in issue linking), not the outward or inward description (ie. Not what you see on the ticket itself)


In which version of Jira are you working? Have you tried to add a condition on the workflow asking for the value field?

Yep, that option is only for versions before the Jira 5. Maybe in a plugin? I'm investigating a little. Do you have a condition called 'Script Condition'?

Ok, so you can install the Script Runner plugin. It adds a condition called 'Script Condition' and there you have the possibility to add a Built-In script to check blank fields or something like that. It's a very good plugin, I use it a lot.

It has this Built-In script for example: Has at least one outward duplicate link

Here is some documentation.

Version 5.0.1

I'm actually looking right now in the workflow at a condition for a transition, but I do not see an option for checking for a value field.

FYI, I just installed JIRA Suite Utitlites plug in and it does not have what I need.

Happily, you won't have to code anything. In that Built-In that I indicated you just need to change the value of 'duplicated' to 'test' or other thing. The script is already built.

Hope you find the solution. And remember to mark the answer if it works.


Thanks Ramiro, I actually have Script Runner installed. I was hoping I didn't have to code up anything to get this to work. I'll have to look into it a bit more. Even if i do get this to work, I see that the Issue Links field is not available via Greenhopper. :(

I'm not entirely sure. This is the script the condition uses:


@JamieEchlin, it is possible to do an 'If' clause or something like that?

Ramiro - thanks I'll try it out and let you know how it goes. Is it possible to perform this action only on certain issue types? I don't want this automatic linking to occur on all issues types, just my custom type "Test".

Yeah, you can put whatever script you like there... no constraints, eg:

if ( == "Task") {
    return issueLinkManager.getOutwardLinks(issue.getId())*'Duplicate')
else {
    return true

I don't mean to be obtuse about this, but it appears as if this script is only a once and done thing? Meaning it's only run on what every Issue ID you specify? Is that correct?

If this is the case, this is not what I'm looking for. What I need is a situation where whenever a sub-task (of type test) is created, it will automatically create a link to it's parent issue.

Awesome, everyday I found new things on the plugin. @jroe with that your issue is completely resolve I think.

If the issue type 'test' is a sub-task it will create the link automatically, because it is a sub-task of a parent issue.

In the case it isn't a sub-task, the workflow will validate that the issue has at least one issue linked everytime and every issue type that it is assigned to that workflow.

What Ramiro is suggesting I believe is that you use the simple scripted validator function from the script runner plugin, which you can put on the Create step or whatever. The "issue" in the script refers to the issue currently being entered.

This will enforce that there is one outward link of whatever type you need. You may need to experiment, or if I have the wrong end of the stick can you clarify what you are looking for.

Jamie & Ramiro -- I really appreciate you sticking with me and helping me out with this. The Script Runner tool is really helping me understand how to tap into Jira's functionality.

Here is where I am with things:

I created this snippet of code that is doing what I want. I tested it in Script Runner.

if ( == "Sub-test") {
	issueLinkManager.createIssueLink (issue.getId(), issue.getParentId(), 10200, 0, issue.reporter);
        return true;

So now my question is, I don't know where to put this? I'm assuming I have to add it as a Post Function in the Create Issue step in the Workflow? If so, I don't see where I can put it? It's asking me to specify a path to the script and all I have is the above code. Is this where I'm supposed to put it? I'm hoping you can point me in the right direction for this.

Thanks for your help so far.

Hi Janine... can you explain again what you need to do? From your question I thought you wanted to validate there was a certain type of issue link for a certain issue type, but your code is creating a link.. and also creating it to its subtask, which I don't think you want. BTW I think you are getting there, we just need some more info...

Well, yes, my original question in this topic was that when I set the "Issue Links" field to be a required field when creating or editing certain issue types (tests and sub-tests), Jira was not validating if the link was set and referencing a Jira issue (it only checks to see if the link type drop down is set, but doesn't take into account the text field to enter the issue to link with.) (Which sounds like a bug to me)

So then it moved into the idea of using Script Runner to validate as part of a workflow. I guess in my mind, my solution shifted from "validating" to more "automating". Meaning, rather than check to see if the user created the link, just create the link behind the scenes. So I was thinking that during a "create issue" if the issue being created is of type "sub-test" (my custom type), then automatically link this sub-test to it's parent with my custom link, "Tests" (outward = tests , inward = is tested by). So that is what my above script is trying to do. However I really don't know where to put this.

I hope that makes some sense. Oh and I was thinking that this automating is only going to work for "sub-test" types, not "test" types (parent type issue).

I would just use the "create a subtask" built-in post-function on the Create step, then the user doesn't need to do anything, if you only want to create a subtask. If you want to create an issue link, that's possible, but it needs to know where to link to.

Hey Jamie,

Well I installed my own version of Jira on my local server so I can test my script out (I've wanted to do that anyway so I can develop my own plug in). Could you tell me where I would need to put the script on the my jira server so it will run as part of the post function? Does it matter where it goes? And would I name it with a .groovy extension? (This is all very new to me, so I'm sorry for the basic questions).

Yes, I'm a little lost here. I thought you wanted to make a condition to validate that the issue has a linked issue. Now I'm not sure. But Jamie is right, you're almost there, and by your self too, that's a good thing :)

Ramiro and Jamie -- you are both being very patient with me, much appreciated. Let me step back to the original question I asked...adding validator check and Jamie's example of a solution:

if ( == "Sub-test") {
    return issueLinkManager.getOutwardLinks(issue.getId())*'Tests')
else {
    return true

I FINALLY saw what it is you were going for with this...AND I found in the workflow the place to put it. In the workflows, Create Issue under the Validators, I saw you can add a Script Validator and use the Simple Scripted Validator, which you can paste an embedded script in there and set what the error message is if it fails validaton as well as indicate what field to associate the error message.

So I did just that, plugged in the above code and tested it. However, what's happening is that it's always failing. And I *think* that the reason for this is that, it's looking for exising links? And on the Create, the link hasn't been created, but rather it's the form field to create I want to check to see if it's valued. Does that make sense? If I am completely wrong about this and it's not working for another reason, then let me know. Regardless, I'm not sure how to get this to work.

thanks again for all your help thus far.

If I understood correctly, you are trying to insert this script in the 'Create' step, is this true? If that's the case it is showing error because when the issue is created doesn't have a issue linked yet. This script can be used for example in the case you want to make sure it has a linked issue before you would be able to 'Resolve' the issue. This script it is only to verify if the issue has a 'Tests' link to another issue but only in case when the issue type is 'Sub-test'.

That sounds plausible... Maybe best to put it as a condition of the outward transitions from open? It should be possible to get the link even though it's not committed yet, I will have a dig around.

@Jamie Echlin,

Thanks a lot for such a wonderful plugin. I also use it, big fan J.

Was trying to make the field ‘Issue Links’ mandatory on the create issue step.

Tried the below script :

“issueLinkManager.getOutwardLinks(issue.getId())*'incorporates') “

This doesn’t work as it checks for already created links, not good to use in Create step L.

Could you suggest any work around ? FYI, I use JIRA 5.1.3.

Thanks, Vishnu.

Is there a way to validate that the "Cloners" link does NOT exist and proceed with issue creation if it doesn't exist?

@Jamie Echlin [Adaptavist] , @Vishnu - I am struggling with the same problem as Vishnu. It is crutial for us that Linked Issues is a required field. We work with JIRA 6.3.9. Any help? Thanks, Radim

@Jamie Echlin [Adaptavist] - I'am facing the same problem.

The validator "“issueLinkManager.getOutwardLinks(issue.getId())*'incorporates') “"

is not working on create transition. We want to force the user to enter value (actually link some issue to the issue being created) for linked issues field upon creation.

We are on JIRA v6.4.4

Thank you!

This solution does not work when the script is set as a validator for the create transition.

set code to below:

import org.apache.log4j.Category
    import com.atlassian.jira.ComponentManager
    import com.atlassian.jira.component.ComponentAccessor
    import com.atlassian.jira.issue.Issue
    import com.atlassian.jira.issue.IssueManager
    import com.atlassian.jira.issue.CustomFieldManager
    import com.atlassian.jira.issue.fields.CustomField
	def Category log = Category.getInstance("com.oncreate.jira.groovy.ValidateFunction")
	log.debug("id: " + issue.getId())
	log.debug(issueLinkManager.getOutwardLinks(issue.getId())*'Root Cause'))
	return issueLinkManager.getOutwardLinks(issue.getId())*'Root Cause')

and the logs generate "id: null" and false for the two log calls.

so obviously failing because the issue is not yet created...

could someone please confirm if there is a workaround to this or not for the create transition. i need this on create so having on another transition is not a valid solution for me (but might be for others of course).

I'm interested by this validator, and facing the same difficulties.

@Alister, Indeed the link is not yet created. The best we could do is to test the values entered in the linked issue field. Indeed, after the custom validators have been checked, the system still controls that the link can be created before executing the transition, so it's still secured.

Unfortunately, I can't figure out how to access the values of this field ("linked issue" and "link type")

Any idea ?

I realize this is an old post, but here in 2019, I was facing a similar issue as the original question: if a user transitions an issue to Closed with the 'Duplicate' resolution, I want the Linked Issue fields to be mandatory. I am doing this with a workflow validator, using Scriptrunner. My problem was indeed that the 'Linked Issues' field has a default, while the 'Issue' field (where you select an issue to link) is blank. The validator regarded this combination as not blank en thus proceeded with the transition.

This is how I got it to work:

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.Issue;
import com.opensymphony.workflow.InvalidInputException

Boolean passesCondition = true;
def request = webwork.action.ActionContext.getRequest();

if (request) {

IssueLinkManager linkMgr = ComponentAccessor.getIssueLinkManager();
def customFieldManager = ComponentAccessor.getCustomFieldManager();
// get Resolution
def resolution = issue.getResolution()?.getName();

// Validator
if (resolution == "Duplicate") {

// Check for outward links of type 'Duplicate'
def outwardDuplicates = linkMgr.getOutwardLinks(issue.getId())*"Duplicate");
// Check for inward links of type 'Duplicate'
def inwardDuplicates = linkMgr.getInwardLinks(issue.getId())*"Duplicate");
// Get formfields
String linkType = request.getParameter('issuelinks-linktype');
String[] linkedIssues = request.getParameterValues('issuelinks-issues');

if (outwardDuplicates || inwardDuplicates) {
passesCondition = true; // Issue already linked as Duplicate
} else if (linkType in ["duplicates", "is duplicated by"] && linkedIssues){
passesCondition = true; // Duplicate issue selected in form
} else {
passesCondition = false; // No issue linked as Duplicate
throw new InvalidInputException("Please link a duplicate issue.")
} else {
passesCondition = true;
return passesCondition; 

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Jira

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

363 views 1 3
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you