Hello World,
Wanted to show the percentage complete on the parent task from the sub-task fields,
Just example:
Parent-Task Completed (Number field) on the Parent task.
Sub-Task Completed (Number field) on the Sub task.
Average of the "Sub-Task Completed" to show on the "Parent-Task Completed".
I have tried scripted number field it work perfectly fine. But I could not get the scripted field to show on Dataplane report, for the reason I have created Number field instead to show on report.
Any script listeners?
Hi,
You can do this with the Field Teller Plugin available on the marketplace. The plugin's capabilities are to display the field on an Issue on another specified Issue.
You can Download it here: https://marketplace.atlassian.com/apps/1224310/field-teller?hosting=server&tab=overview
This code seems to be working
def issue = event.issue as Issue
//Subtask change event
def change = event?.getChangeLog()?.getRelated("ChildChangeItem").find {it.field == "Sub-Task Percentage Complete"}
if (! change) {
// there was no update do nothing!
return
}
if (! issue.isSubTask())
return
double total
double totalSum
double parentsum
def subTaskSum = 0
issue.getParentObject().subTaskObjects?.each {subtask ->
def cf = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_10009")
def cfValue = subtask.getCustomFieldValue(cf)
if (cfValue != null) {
totalSum += subtask.getCustomFieldValue(cf) as double
}
subTaskSum += 1
}
total +=totalSum as double
parentsum = total / subTaskSum as double
log.warn "total :" +total
log.warn "average :" +parentsum
//Get the parent object
MutableIssue parentIssue = issue.getParentObject();
def parent = ComponentAccessor.getCustomFieldManager().getCustomFieldObject("customfield_14315")
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def changeHolder = new DefaultIssueChangeHolder()
parent.updateValue(null, parentIssue, new ModifiedValue(parentIssue.getCustomFieldValue(parent), parentsum),changeHolder)
Regards
Tejas
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.