Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,298,315
Community Members
 
Community Events
165
Community Groups

Increment Custom Field on Transition

Edited

Hello :)

I'm trying to automatically increment a counter when a card issue passes through a specific transition.

After my QA team testing procedure, the issue can pass through "test rejected" transition and i would like to count every time it happens for the same issue (Counting rework).I think about a custom field counting it.

Does anyone have some suggestion dealing with this without plugins (or using only automation for JIRA)? Maybe a different approach?

6 answers

9 votes

Hello @lucas_almeida

Thank you for reaching out.

Per your description, I understand you would like to increment a custom field by 1 every time you transition your issue to a specific status. Is that correct?

You can definitely create a custom number field and use an automation rule to properly increment the field when a specific transition occurs. These would be the steps:

  1. Create a number custom field and add to your issues. P.S: In my own site that I will use as an example, I named it as "increment".
  2. Navigate to your project > Project settings > Automation and create the following rule, using the Smart value "{{#increment}}{{issue.yourcustomfield}}{{/}}" to increment the field value and selecting the status you want it to be updated:
    Screen Shot 2020-05-27 at 17.20.43.png

For more details about the instruction provided and how to handle numerical values with Jira automation, check the documentation below:

Use smart values to insert numerical values 

Let us know if this information helps.

hi. i've been set the smart value. 

on the first time, the field successfully updated (from 0 to 1).  but for the second time so on, it failed to increment the value (value still 1). 

can you help me ?

Screenshot from 2020-09-01 16-55-30.pngScreenshot from 2020-09-01 16-54-39.pnghere the audit log

Screenshot from 2020-09-01 17-04-33.png

Were you able to solve this? I'm having the exact same issue, works only the first time 

Humn!!! I'm also having same issue... Help appreciated

  

If it helps, I created a new custom field with a different name and it worked fine... I couldn't figure out why it didn't work for the old one. 

I had a typo in the field name in issue.yourcustomfield. After correcting, it started to increase the number nicely.

@julie naglestad 

Can you share a snip of the automation rule details to help us try and troubleshoot?

Obviously maybe grey out or hide anything that might be sensitive!

Thanks

Lewis

Hey guys,

To increment a custom field. This is what I did and it seems to be working properly.

In the example below, I'm incrementing the rejection count by 1 each time the ticket is rejected. Hope this helps!

Screenshot 2021-11-10 at 1.57.30 PM.png

Working for me. Thanks.

I ended up using the Advanced field editing to get this to work:

 

{
"update": {
"customfield_10039": [{
"set": {{#increment}}{{issue.customfield_10039}}{{/}}
}]
}
}Screen Shot 2021-11-10 at 2.04.29 PM.png

For anyone else that has the issue of only incrementing to 1 and not beyond.

 

I'd originally gone with the name of the field in the automation e.g. DaysInCurrentStatus for the field "Days In Current Status". Switching this to use the customfieldID resolved the problem.

E.G:

{{#increment}}{{issue.customfield_11566}}{{/}}

Issue details are viewable via a link like below:

https://[YOURINSTANCEDETAILS].atlassian.net/rest/api/2/issue/[YOURISSUEKEY]

I'm unable to get my field to increment even to 1. Call me stupid, but can you give an example of what exactly you put in [YOURINSTANCEDETAILS] and [YOURISSUEKEY]?

Cool this actually worked. Small change I did was use this link -> https://[YOURINSTANCE].jira.com/rest/api/2/field to get my custom ID

@A D Sugar ,

Apologies I did write a response to this but my browser clearly decided no!

Your instance details will be visible in the URL when you are on any Jira page. If you worked at ACME for example it would be:

https://acme.atlassian.net

Issue key is just the Jira number reference for one of your issues that you want to view the underlying details (such as the custom field ID for your custom field you want to increment. So if you have a project for "Road Runner Traps" you might see an issue id:

RRT-50

Hopefully that all makes sense and gives you a couple of more tools to aid in automating processes in Jira.

Thanks

Lewis

Like A D Sugar likes this

Thank you, Lewis. That is very helpful!

Hi

 

You don't need to re-fetch or use advanced editing, you just need to use the math calculation smart value which is {{#=}}{{/}} then in between stick your calculation using the field smart value with the calculation you want to do, in this case, +1.

 

{{#=}}{{Initial Size}}+1{{/}} but the {{#=}} is more for advanced math instead of a simple increment.

 

It also works with

 

{{#increment}}{{Initial Size}}{{/}}

 

It also supports using a different number {{#increment}}{{Initial Size}}+2{{/}}

 

Here's an extreme example

large increase.PNG

large increase history.PNG

Screen Shot 2021-11-10 at 2.06.10 PM.pngI ended up using the Advanced field editing to get this to work:

 

{
"update": {
"customfield_10039": [{
"set": {{#increment}}{{issue.customfield_10039}}{{/}}
}]
}
}

You can also decrement the field using the advanced field editingScreen Shot 2021-11-10 at 2.10.31 PM.png

For those who hit a problem, I solved it by re-fetching the issue data. Believe the rule repeatedly adds to the original value thus does not adds the second time. Hopes this helps someone.  

This. Because transition in issue doesn't refresh the whole page, you won't see it increment before your very eyes without a refresh. I also noticed a very short delay, maybe 30s at most.

The top solution with {{#increment}}{{issue.myCustomFieldName}}{{/}} is working consistently for me.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Published in Jira Software

Upcoming changes to epic fields in company-managed projects

👋 Hi there Jira Community! A few months ago we shared with you plans around renaming epics in your company-managed projects. As part of these changes, we highlighted upcoming changes to epics on...

14,850 views 37 48
Read article

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you