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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

246 views 1 18
Join discussion

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