Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

The Sub-Task Estimated Story Points count added to the Parent Estimated Story Points field

siva
Contributor
August 2, 2022

Hello,

My issue is accumulate the Sub-Task Estimated Story Points  to the Parent Estimated Story Points field and we are using jira server. 

However by using scriptrunner listener created the script but that the  script only sums up the  Sub-Tasks Estimated Story Points and does not calculate the Parent one.

As an example:

If parent had 3 Estimated Story Points and Sub-Task-1 had 5 Story Points and Sub-Task-2 had 6 Story Points, then normally 3+5+6=14 story points are calculated and listed in parent Estimated Story Points field , but our current script only calculates Sub-Tasks 5+6=11 and this 11 is updated on Parent "Estimated Story Points" while "3" parent story points are completely gone. Please assist me in determining where I modified the script, and your assistance will be greatly appreciated. Here is the script:

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.ModifiedValue
import com.atlassian.jira.issue.util.DefaultIssueChangeHolder
import com.atlassian.jira.issue.index.IssueIndexingService

def issue = event.issue
def eventName = ComponentAccessor.eventTypeManager.getEventType(event.eventTypeId).name
def cfStoryPoints = ComponentAccessor.customFieldManager.getCustomFieldObjectsByName("Estimated Story Points").first()

if (issue.parentObject != null) {
def subTasks = ComponentAccessor.subTaskManager.getSubTaskObjects(issue.parentObject)
int intStoryPoints = 0 + (eventName == "Issue Created" ? (issue.getCustomFieldValue(cfStoryPoints) != null ? ((issue.getCustomFieldValue(cfStoryPoints).toString() as Double) as Integer) : 0) : 0)
subTasks.each {
intStoryPoints += (it.getCustomFieldValue(cfStoryPoints) != null ? ((it.getCustomFieldValue(cfStoryPoints).toString() as Double) as Integer) : 0)
}
cfStoryPoints.updateValue(null, issue.parentObject, new ModifiedValue(issue.parentObject.getCustomFieldValue(cfStoryPoints), intStoryPoints as Double), new DefaultIssueChangeHolder())
ComponentAccessor.getComponent(IssueIndexingService).reIndex(event.issue)
}

Here is my screen shot how i configure the listener

Estimated Sory points.png

Thanks,

Siva.

2 answers

0 votes
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 3, 2022

I know this is not an answer to your question, but I need to question why you are doing this.

Are you using "Estimated Story Points" as your board estimation statistic?

0 votes
Aditya Sastry
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 3, 2022

Hi Siva,

You are not adding issue.parentObject.getCustomFieldValue(cfStoryPoints) to intStoryPoints before updating in the listener. 

Kindly do that and it should start working as expected.

Thanks,

Aditya

Suggest an answer

Log in or Sign up to answer