Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Get Linked Issues of Epic-Story-Link-Type

Stefan Niedermann February 12, 2014

Hello,

i need to get all linked issues of an issue.

This works fine with any link type, but not with the "Epic-Story Link"-Type.

This is my code:

String linkName = "01 Verfeinerung";

    java.util.List<Issue> next_level = null;

    IssueLinkManager lm = ComponentManager.getInstance().getIssueLinkManager();
    ServletValueStack valStack = (ServletValueStack)request.getAttribute("webwork.result");

    ViewIssue vi = null;
	for (java.util.Iterator i = valStack.iterator(); i.hasNext();) {

		Object o = i.next();
		if (o instanceof ViewIssue) {
			vi = (ViewIssue) o;
			LinkCollection lc = lm
					.getLinkCollectionOverrideSecurity(vi.getIssueObject());
				next_level = lc.getOutwardIssues(linkName);
				if (next_level == null) {
					next_level = lc.getOutwardIssues(epicLinkName);
				}
			break;
		}
	}

If the linkName is a "normal" link, all works fine, but if i insert "Epic-Story Link", it does not work.

I checked the database, there is an entry called "Epic-Story Link".

1 answer

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

1 vote
Answer accepted
Stefan Niedermann February 13, 2014

Solution:

Get the Epic through the value of the field "Epic-Link" in the Story.

CustomFieldManager cfm = ComponentAccessor.getCustomFieldManager();
IssueManager im = ComponentAccessor.getIssueManager();
					
CustomField cf = cfm.getCustomFieldObject(new Long(14122));
// Get current story issue
Issue storyIssue = im.getIssueObject(vi.getId());
				
// Get epic id from epic link field
Issue epicIssue = (Issue) cf.getValue(storyIssue);
					
// Get epic issue with epic id
if(epicIssue != null) {
	next_level = new ArrayList();
	next_level.add(epicIssue);
}

TAGS
AUG Leaders

Atlassian Community Events