How to create an Epic link programmatically in an issue? Edited


I have developed an add-on which has the capability to connect to our remote application and import security vulnerabilities into Jira server as Jira issues.

During the import process (programmatically), I create an issue as per given configurations and one of the configuration is Epic link. So when I create issues, Epic link should be populated with them. Anyway I managed to create issues with given all the configurations (IssueType, Assingee, reporter, Labels, Description etc.) except Epic link. Epic link is not get set.

I used the following code snippet to create issues and set Epic Link but it is never succeeded.

One thing I noticed is that all the String type data fields are get set to the issue objects successfully but when I try to set Object type data field, it is not get set to the issue object. Epic Link is a Object data type.


// First Create an MutableIssue
MutableIssue newJIRAIssue = ComponentAccessor.getIssueFactory().getIssue();

// Then we create an Custom field for Epic link
CustomFieldManager cfMgr = ComponentAccessor.getCustomFieldManager();
CustomField epicCustomField = cfMgr.getCustomFieldObjectByName(“EPIC LINK”);

// Then we get the existing Epic issue
MutableIssue epicIssue = ComponentAccessor.getIssueManager().getIssueObject(“Epic-234”);

// Then we set the Epic link to the newly created MutableIssue
newJIRAIssue.setCustomFieldValue(epicCustomField, epicIssue);

try {
       // We try to create the issue with all the setting including Epic link. But we get always get NoSuchMethodError exception in JIRA 7.x.x

returnIssue = issueManager.createIssueObject(user, newJIRAIssue);

       } catch (java.lang.NoSuchMethodError e) {

           //Then we try reflection as following to create the issue. It creates the issue successfully but the given Epic link has been not set to the issue

Class<?> givenObjectClass = issueManager.getClass();

                for (Method m : givenObjectClass.getMethods()) {
                     if (m.getName().equals("createIssueObject")// We also validate parameter list here to determine exact overloaded method) {

                        objectReturned = m.invoke(givenObject, givenParameters);
                        return objectReturned


0 answers

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,088 views 4 9
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