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(Story and bug tickets).
However I need to link these stories to epics and bugs to stories (programmatically) respectively. Anyone here who has tried this before or have an idea on how to proceed with this?
Below are two approaches I have tried
Approach 1- Update the epic link of an issue that is already created.
MutableIssue missue = issueManager.getIssueObject(jiraIssue.getKey());
CustomFieldManager cfMgr = ComponentAccessor.getCustomFieldManager();
CustomField epicCustomField = cfMgr.getCustomFieldObjectByName("Epic Link");
MutableIssue epicIssue = issueManager.getIssueObject("B1-976");// This is my epic
epicCustomField.updateValue(null, missue,
new ModifiedValue(missue.getCustomFieldValue(epicCustomField), epicIssue),
new DefaultIssueChangeHolder());
Approach 2- Set Epic link when a new issue is being created
MutableIssue newJIRAIssue = ComponentAccessor.getIssueFactory().getIssue();
CustomFieldManager cfMgr = ComponentAccessor.getCustomFieldManager();
CustomField epicCustomField = cfMgr.getCustomFieldObjectByName("Epic Link");
MutableIssue epicIssue = ComponentAccessor.getIssueManager().getIssueObject("B1-976");// This is my epic
newJIRAIssue.setCustomFieldValue(epicCustomField, epicIssue);
Both approaches are not working. The issues are created/updated successfully with all other custom fields except the Epic Link.
Any help on this will be highly appreciated.