Workflow Increase or de-crease field value parent issue?

Kevin Seery November 14, 2017

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
Kevin Seery November 21, 2017

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

Kevin Seery November 28, 2017

Hi,

Can anyone offer any help?

 

Thanks

Kevin

0 votes
Joshua Yamdogo @ 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.
November 14, 2017

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?

Kevin Seery November 15, 2017

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

Kevin Seery November 17, 2017

Hi Joshua,

 

Can you offer any more help?

 

Many Thanks

Kevin

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 17, 2017

What help are you looking for? 

Kevin Seery November 21, 2017

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 November 21, 2017

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

Suggest an answer

Log in or Sign up to answer