Why Jira doesn't create link between issues?


We use JIRA 6.2.7 in our firm. Also we use Script Runner plugin.

We would like to automatically create issues, when specific issue type is created.

We wrote script (triggered by Scriptrunner) which do this.

Problem is, that in 1 of 20 attempts, JIRA doesn't create issue link between parent and subissue. In other 19 attempts, everything is all right.

When I look at history at affected issues where should be link, I see that links there, but issues aren´t actually linked. As you can see in screenshot.

Have someone any idea, where can be problem?


bug jira link.png

7 answers

have you tried reindexing?

such behaviour is often related to wrong list or array dimensions. let us see the code of the script

Re-indexing didn't help.

You can see our script here:

package com.libgroovy;
import java.util.HashMap;
import java.util.Map;
import org.apache.log4j.Logger;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.event.issue.AbstractIssueEventListener;
import com.atlassian.jira.event.issue.IssueEvent;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.MutableIssue;
class NewIssueCreated extends AbstractIssueEventListener {
    Logger log = Logger.getLogger("com.onresolve.jira.groovy.NewIssueCreated");
    void createTickets(java.util.ArrayList ticketNames, long linkType, IssueEvent event)
      def ticketName = "";
      def newIssueType;
      def issueType = 3;                 
      ticketNames.each() {
          ticketName = "${it}";
          newIssueType = (ComponentAccessor.getConstantsManager().getAllIssueTypeObjects()).find{it.name=="${ticketName}"};
          if (newIssueType)
              issueType = newIssueType.getId();
          // newIssueType = ComponentAccessor.issueTypeSchemeManager.getIssueTypesForProject(event.issue.projectObject).find{it.name=="${ticketName}"}
          MutableIssue issueObject = ComponentAccessor.getIssueFactory().getIssue();
          //issueObject.setProject(ComponentManager.getInstance().getProjectManager().getProject(new Long(10601)));
          issueObject.setSummary("${event.issue.getSummary()} - ${ticketName}");
          // issueObject.setAssignee(event.issue.getAssignee());
          issueObject.setDescription("Auto: ${ticketName}");
          Map params = new HashMap();
          params.put("issue", issueObject);
          Issue newIssue = ComponentAccessor.getIssueManager().createIssueObject(event.getUser(), params);
          // ImportUtils.setIndexIssues(true);
          // ComponentManager.getInstance().getIndexManager().reIndex(newIssue);
          // ImportUtils.setIndexIssues(false);
            //check if the link really exists - sometimes it doesn't work, but no error is raised
            int linkedIssueCount = ComponentAccessor.getIssueLinkManager().getLinkCollectionOverrideSecurity(newIssue).getAllIssues().size(); 
            log.info("Issue "+newIssue.getKey()+" linked issue count: " + linkedIssueCount);
            if (linkedIssueCount > 0)
              log.info("Issue "+newIssue.getKey()+": a link to issue "+event.getIssue().getKey()+" created.");
          catch (Exception e)
            log.error("Issue "+newIssue.getKey()+": error when creating a link to issue "+event.getIssue().getKey()+".", e);
    void workflowEvent(IssueEvent event) {
      log.info("NewIssueCreated-Copy2.groovy: Workflow event fired for issue " + event.getIssue().getKey());
      def projectKey = event.getIssue().getProjectObject().getKey();
      def ticketNames = [];
      def ticketNames2 = [];
      def linkType = 10303;              
      def linkType2 = 10303;
          ticketNames = ["Solution Design", "Test Scenario", "Development","Parametrization","Documentation", "Automated Test","Test"];
          linkType = 10601;
          ticketNames2 = ["Bug Fixing"];
          linkType2 = 10502;
      }else if((event.issue.getIssueTypeObject().getName()).equals("BREQ") ) {
          ticketNames = ["Bug Fixing"];
          linkType = 10501;
      }else if((event.issue.getIssueTypeObject().getName()).equals("Simple Enhancement")) {
          ticketNames = ["Bug Fixing"];
          linkType = 10700;
      createTickets(ticketNames, (long) linkType, event);
      createTickets(ticketNames2, (long) linkType2, event);

The script looks good to me. I don't see any potential problems. And you would probably see some Exceptions if there was any. The activity stream of your affected issue clearly shows that the link was set. Are you sure that the link is definetely missing (sometimes)? check that issue linking is enabled. check that the issue linking panel is enabled in plugins menu.

Link was set, but issues aren´t actually linked...
I tried create link between issues by myself and it works.
In activity stream it looks same like before with script. (just link appear)


How I said, script create issues and link correctly in 95% of cases.
Only random 5% of created issues is "bugged"
Issue linking is enabled and linking panel is enabled too.

PS: sorry for writing new answers always, but I can´t insert screenshot and code to comment.

realy mysterious that there is actually a trace of the link in activity stream. I cannot imagine that it is possible to create history entry without having created the link first. The link description and linked issues summary must have been coming from somewhere. So, either the link was deleted after it was created somehow, or the link exists but is not being rendered for some reason. can you check the other side of the missing link? What does the history of the other issue say, that should have been linked? Is there also a corresponding entry in activity stream? when a link is created there are history entries created on both linked issues usually.

one thing that i've noticed. When you create the link manualy, the history entry looks different. When the link was created with the script, you can see "Field", "Original Value" and "New Value". But when you create it manually, you don't see that.

Also, please check if source and destination issues are in correct order when you create link like this: ComponentAccessor.getIssueLinkManager().createIssueLink(newIssue.getId(),event.getIssue().getId(),linkType,(long)0,event.getUser()); Sure that the new Issue is your source issue for the link?

Ad1) Other side of link is actually same. In history I can see link to bugged issue.



Ad2) Field, Original Value and New Value Jira shows only when first entry is added. In every situaton, if u have few similar entries, Jira shows descriptions only above first of all.
Ad3) I think, that´s also correct. As I said, cca 95% of created issues are fine, only random cca 5% are bugged.

mystery. if youre saying that there is activity stream trace in both issues that are supposed to be linked, then i am pretty sure that the link was actually created and has at least existed. Maybe it actually exists, but is just not being shown for some reason. (i.E. Exception during rendering of Linking Panel on Issue Screen). Anyway, you must try to figure out the condition when the issues get buggy. There must be something special about them.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Jan 08, 2019 in Jira

How to Jira for designers

I’m a designer on the Jira team. For a long time, I’ve fielded questions from other designers about how they should be using Jira Software with their design team. I’ve also heard feedback from other ...

1,196 views 5 10
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