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
Thanks,
Siva.
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?
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.