Workflow Increase or de-crease field value parent issue?

Hi,

 

I would like to increase or de-crease a field value on the parent issue. When sub task transition workflow.

 

Could not find a script todo this we use JMWE and Script runner.

 

Many Thanks

Kevin

 

2 answers

Hi Kevin,

I think your best bet would be to set up a workflow post-function. The post-function would work something like this:

  • An issue is transitioned through the workflow
  • Post-function checks to see if the issue type is "sub-task"
  • If the issue is a "sub-task", update the custom field value on the parent issue
  • Parent issue now has updated value

Does that sound correct?

Hi Joshua,

This is correct, it would increase the count on a custom field on the parent.

Also, if the sub-task is move in error, then the transitioned workflow decrease the count on the perant custom field.

Many Thanks

Kevin

Hi Joshua,

 

Can you offer any more help?

 

Many Thanks

Kevin

What help are you looking for? 

Hi Nic,

 

For ease of reporting I need to have a couple of fields on my parent issue. 

The number of sub-tasks of x type

The number of sub-tasks of x type that are completed

I need setup a listener for this can you point me at a script to-do this.

Many thanks just learn JIRA

Kevin

Kevin Seery 3 seconds ago

Hi Nic,

Found these scripts

This one give me the count I wanted: 

issue.getSubTaskObjects().findAll {
it.getIssueTypeObject()?.getName() == "Project Capitalisation"
}.size()

 

Trying to change this one give me a count of issue type and status:


int numSubtasks = issue.getSubTaskObjects()?.size()?:0
if (numSubtasks>0) {
int numClosedSubtasks = issue.getSubTaskObjects()?.getName() == "Project Capitalisation".count{it?.statusObject?.name=='Closed'}?:0
return (numClosedSubtasks/numSubtasks) as Double
} else {
return 0 as Double
}

 

Do you have any pointers?

Many Thanks

Kevin

Hi Nic,

Found these scripts

This one give me the count I wanted: 

issue.getSubTaskObjects().findAll {
it.getIssueTypeObject()?.getName() == "Project Capitalisation"
}.size()

 

Trying to change this one give me a count of issue type and status:


int numSubtasks = issue.getSubTaskObjects()?.size()?:0
if (numSubtasks>0) {
int numClosedSubtasks = issue.getSubTaskObjects()?.getName() == "Project Capitalisation".count{it?.statusObject?.name=='Closed'}?:0
return (numClosedSubtasks/numSubtasks) as Double
} else {
return 0 as Double
}

 

Do you have any pointers?

Many Thanks

Kevin

Hi,

Can anyone offer any help?

 

Thanks

Kevin

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted Oct 16, 2018 in Jira

Looking for anyone who made the switch to Data Center

The Jira Marketing team is putting together an ebook on migrating to Data Center. We're looking for pro tips on how you staffed your project team and organized your Proof of Concept. Share yo...

1,385 views 17 10
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you