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

0 votes

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 Join to answer
Community showcase
Sarah Schuster
Posted Jan 29, 2018 in Jira

What are common themes you've seen across successful & failed Jira Software implementations?

Hey everyone! My name is Sarah Schuster, and I'm a Customer Success Manager in Atlassian specializing in Jira Software Cloud. Over the next few weeks I will be posting discussion topics (8 total) to ...

3,104 views 13 19
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
Atlassian Team Tour

Join us on the Team Tour

We're bringing product updates and pro tips on teamwork to ten cities around the world.

Save your spot