Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Automatically Increment and Decrement Custom Field on Transition in Jira cloud

Janaki.R
Contributor
March 16, 2022

Hi Team,

 

We have two number custom fields when issue is getting transitioned to next stage we wanted to increment 1st custom field value and decrement second custom field value using script runner post function.

Right now using below script for incrementing the value but its not working.

def currValue = (Double)issueInput.fields.customfield_10051 ?: 0 issueInput.fields.customfield_10051 = currValue + 1.0

There are so many answers for the same question in server but we want this to implement this in cloud

Thanks in advance!!

1 answer

1 accepted

2 votes
Answer accepted
Callum Carlile _Automation Consultants_
Community Champion
March 16, 2022

Hi @Janaki.R 

I'm not 100% sure how you can do this in ScriptRunner, however if you're using Cloud you could quite easily do this in an automation rule.

The trigger would be the transition, then you could use the Edit Issue action containing something like:

{{#=}}{{customfield_10051}} + 1{{/}} - This uses the math expression smart value to add 1 to the current value within customfield 10051

Janaki.R
Contributor
March 16, 2022

Hi @Callum Carlile _Automation Consultants_ ,

Thanks for your reply

 

Yeah, i am aware that this can be achieved by automation but the issue is when the value is getting incrementing the issue should automatically transits the next stage so i have written two automations one for incrementing the value and second one whenever value is changing and it satisfies particular condition it should move to other state. This automations are working fine induvidually and i wanted to trigger this rules parallely but at a time only  automation is working. so i wanted to change incrementing the value with script runner and moving the transition if condition satisfied with automation

Callum Carlile _Automation Consultants_
Community Champion
March 16, 2022

@Janaki.R Ah okay, fair enough.

I'm not sure why the automation rule might not be working, but just one thing to quickly check - have you checked this checkbox on the second one that's triggered off the first one? This is required when one rule is triggering off the action of another rule

checkbox1.PNG

Janaki.R
Contributor
March 16, 2022

@Callum Carlile _Automation Consultants_ 

Awesome!! I missed to check that box after checking that two automations are working as expected.

Thanks for your help

Callum Carlile _Automation Consultants_
Community Champion
March 16, 2022

No worries!

Suggest an answer

Log in or Sign up to answer