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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

update epic story points when story in epic updated


Hi. I am trying to create a listener to run whenever the "story point" field for non-epic issues are updated. I would like the listener to get the issue epic link and then run through all the issues in that epic summing up the story points and then write that to the epic story point field. 

I have used a mish mash of cut and pastes from various posts and come up with this .. but it doesnt work .. there is no failure and  no information so i can not see what is going wrong. I dont know how to use preview in listener so can really test it. Any advice or suggestions would be much appreciated:


import com.atlassian.jira.component.ComponentAccessor
import groovy.xml.MarkupBuilder
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.fields.CustomField;

import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder

//get issue
def issue = event.issue as Issue

//now get epic

def customFieldManager = ComponentAccessor.getCustomFieldManager()

//def epicLinkCf = customFieldManager.getCustomFieldObjectsByName("Epic Link")
def epicLinkCf = customFieldManager.getCustomFieldObjects(event.issue).find { == "Epic Link"}

def epicIssue = issue.getCustomFieldValue(epicLinkCf) as Issue

if (epicIssue) {
// (epicIssue.getCustomFieldValue(epicCustomField))

def epicCustomField = customFieldManager.getCustomFieldObjectsByName("Story Points") //change to your Epic custom field's name

//now get story points of issues in epic
def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def links = issueLinkManager.getOutwardLinks(

def writer = new StringWriter()
def xml = new MarkupBuilder(writer)
def cfManager = ComponentAccessor.getCustomFieldManager()

def cfStoryPoints = cfManager.getCustomFieldObjects().find{ == "Story Points"}
def cfStoryPointsTotal = 0


links.each {issueLink ->

if ( == "Epic-Story Link") {
def linkedIssue = issueLink.destinationObject

cfStoryPointsTotal = cfStoryPointsTotal += linkedIssue.getCustomFieldValue(cfStoryPoints) ?: 0




// write the total values to the epic
def changeHolder = new DefaultIssueChangeHolder()
// get epic story points field

def tgtEpicField = customFieldManager.getCustomFieldObjects(epicIssue).find { == "Story Points"}

tgtEpicField.updateValue(null, issue, new ModifiedValue(epicIssue.getCustomFieldValue(tgtEpicField), cfStoryPointsTotal ),changeHolder)

1 answer

Easiest is to add log info in your script...

There is no issue update (save the issue) in your script ? (nor a re-index of the issue ?)...

But... why having a field updated by listeners ? Isn't a scripted field on the Epic much easier (no worry about saving, indexes, ...)?

Code might be something like (did not add the import stuff)

IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
CustomFieldManager customFieldManager = ComponentAccessor.getCustomFieldManager()

CustomField cfSPts = customFieldManager.getCustomFieldObjectByName("Story Points")
BigDecimal storyPoints
issueLinkManager.getOutwardLinks(issue.getId()).each {epicLink ->
if (epicLink.getIssueLinkType().getName() == "Epic-Story Link") {
Issue epicLinkedIssue = epicLink.getDestinationObject()
if (epicLinkedIssue.getCustomFieldValue(cfSPts)) {
if (!storyPoints) {storyPoints = 0.0}
storyPoints += (BigDecimal) epicLinkedIssue.getCustomFieldValue(cfSPts)
if (storyPoints) {
return storyPoints.toDouble()
} else {
return null

Thanks Marc . I will check out your script tomorrow when back at work but I just wanted to reply to your question : "But... why having a field updated by listeners ? Isn't a scripted field on the Epic much easier (no worry about saving, indexes, ...)?"

The reason I wanted a field update listener is so that the epics story point value will be updated as soon as an issue (in the epic) story point value is updated .. and so can be used in a report or when someone looks at the epic kanban board straight away 

I thought that if i used a scripted field then it would require someone to open / view the epic before the epics story point field was recalculated .. 

is my assumption wrong ? ie if i use a scripted field will the epic story point summation be updated without having to open the epic ? 

thanks again 

We use a lot scripted fields, and they are correctly updated everywhere in Jira (Reports, Boards, other plugins, even in REST calls to Jira) !

Suggest an answer

Log in or Sign up to answer

Atlassian Community Events