Our new Appfire Documentation Space is now live!

Take a look here! If you have any questions please email support@appfire.com

Skip to end of metadata
Go to start of metadata

You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 2 Current »

Abstract

This code snippet calculates the sum of the story points of all issues in an Epic.

Logic

Iterate over issues in the Epic, and sum up the values of the Story Points custom field.

SnippetĀ 

import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.issue.link.IssueLinkManager;

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField customFieldObject = customFieldManager.getCustomFieldObject("<ID of Story Points custom field>");

Double total = 0;
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager();
for (IssueLink outwardLink : issueLinkManager.getOutwardLinks(issueObject.getId())) {
    if (outwardLink.getIssueLinkType().getName() == "Epic-Story Link") {
        Double sp = customFieldObject.getValue(outwardLink.getDestinationObject());
        if (sp != null)
            total += sp;
    }
}
return total;

Placeholders

PlaceholderDescriptionExample
<ID of Story Points custom field>The ID of the Story Points custom field, as found on the Custom Fields page.customfield_10008

Examples

This code snippet can be used as the formula of a Calculated Number Field:


<!-- @@Formula:
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.issue.CustomFieldManager;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.issue.link.IssueLinkManager;

CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager();
CustomField customFieldObject = customFieldManager.getCustomFieldObject("<ID of Story Points custom field>");

Double total = 0;
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager();
for (IssueLink outwardLink : issueLinkManager.getOutwardLinks(issueObject.getId())) {
    if (outwardLink.getIssueLinkType().getName() == "Epic-Story Link") {
        Double sp = customFieldObject.getValue(outwardLink.getDestinationObject());
        if (sp != null)
            total += sp;
    }
}
return total;
-->


Filter by label

There are no items with the selected labels at this time.

  • No labels