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

Creating Issue Link

Can anybody help me out in creating link between 2 issues using groovy? Its very urgent. I have two issues which are doing handshake i.e there values are selected by using PLugin named Query Custom Issue Field. So once i select that ticket there should be link to be created and also de-link.

6 answers

1 accepted

0 votes
Answer accepted

Could you clarify the question a little?

Do you simply want to create links between issues with groovy? If so, where are you doing it? A post function?

What has the "query custom issue field" got to do with these links? From what I've seen, the plugin doesn't the have anything to do with issue links, although it duplicates some of the functionality.

Yes i want to create a link between 2 issues, i have grabbed there value.
I have tried opening this link but its not working.

JIRA:Automatically Linking Issues with a Script During Create Transition

We want to follow which issues found in which test and review sessions. In order to do this we have defined 2 new issue types called “Review Task” and “Test Task”. We have also defined a new relation called “found in”. As a improvement we also do not want to manually link issues found during a test or review to its parent task. To make the process a little bit strait forward we have added a new custom field called “Parent Task ID” to our bug issue type. While creating a bug we just enter the parent task id to this field and a workflow post function automatically links two issues with each other. Also we check validly of parent task id field with another workflow validation script. The only problem is we do not have autocomplete for parent issue id field. Any improvement is welcome.

  • First of all you should install Script Runner plugin. This plugin allows you to customise your workflows with groovy scripts without writing a whole custom plugins.
  • Define a parent issue type and customise it in the way you want. We use Review Task and Test Task issue types.
  • Define a custom field named “Parent Task ID” and add it to every other issue type that you want to automatically associate with a parent issue type (the ones you have defined above).
  • For the Create transition of workflow add following validator to validate correctness of entered “Parent Task ID” field.
    def parentTaskID = cfValues['Parent Task ID']; if (parentTaskID == null || parentTaskID == '') { return true; } else { def parentIssue = ComponentAccessor.getIssueManager(). getIssueObject(parentTaskID); def isValid = parentIssue != null && parentIssue.projectObject.key == issue.projectObject.key && ( == 'Review Task' || == 'Test Task'); return isValid; }

  • Create a linkIssues.groovy file with below scrip content and put it to home folder of your JIRA installation. For the default installation on windows it is the bin folder. After that add script post function to invoke linkIssues.groovy file for Create transition. As you see in the last screen shoot this step should come after “Create the issue originally” step otherwise you will not have an issue id for linking.
    def ComponentManager componentManager = ComponentManager.getInstance(); def customFieldManager = componentManager.getCustomFieldManager(); def parentTaskIDCF = customFieldManager. getCustomFieldObject('customfield_10517');//write your own custom field id here def parentTaskID = issue.getCustomFieldValue(parentTaskIDCF); if (parentTaskID == null || parentTaskID == '') { return true; } else { def issueManager = ComponentAccessor.getIssueManager(); def parentIssue = issueManager.getIssueObject(parentTaskID); def isParentIssueValid = parentIssue != null && parentIssue.projectObject.key == issue.projectObject.key && ( == 'Review Task' || == 'Test Task'); if (isParentIssueValid) { def issueLinkManager = ComponentAccessor.getIssueLinkManager(); def issueLinkTypeManager = componentManager. getComponentInstanceOfType(IssueLinkTypeManager.class); def issueLinkType = issueLinkTypeManager. getIssueLinkTypesByName('Found In').get(0); def authenticationContext = componentManager. getComponentInstanceOfType(JiraAuthenticationContext.class); issueLinkManager.createIssueLink(,,, 1L, authenticationContext.user); } }


I am able to open the link and thier contains shown above.


Onkar Ahire

but this is not what i am looking for.

Can we create link like:

linkManager.createIssueLink(opt.getStatusObject().getId(),issue.getStatusObject().getId(),issueLinkTypeManager.getIssueLink(,1 , currentUser)

but in my case i dont know from where to get all the parameter values?

So any help?

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Marketplace Apps & Integrations

Expose your beautifully crafted Dashboard through the Jira Service Desk Customer Portal

  A picture is worth a thousand words, especially when you're trying to find relationships and understand your data. Here, Dashboards play a vital role in gaining insights from a variety of dat...

286 views 5 4
Read article

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