Forums

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

Incrementing number custom field on transition

Nathan Price
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 15, 2025

Hi, 

I am trying to setup an automation that will increment a number custom field by 1 each time it cycles through the relevant stages. 

The problem I am encountering is that however it set these rules up, the field will only increment from empty to 1, when it cycles through the stages again, the field will not increment from 1 to 2 and so on.

I have tried variations of math operators in the edit issue action, all result in the same, the current format I am using is below

{{#increment}}{{issue.customfield.customfieldID}}{{/}}

When checking the automation audit logs, it states all conditions were met, and the action was successful. Yet the field remains at 1.

I am sure I am missing something, but I see this has been an issue for others in the community, but from reading the forums could not see a clear answer.

From testing it seems the above just sets the field to 1 as opposed to incrementing. If I manually set the field to empty, 0 or 2 for example, cycling through the stages updates the field to 1 every time.

Thank you in advance.

 

2 answers

1 accepted

5 votes
Answer accepted
Aaron Pavez _ServiceRocket_
Community Champion
January 15, 2025

Hi @Nathan Price 

The increment variable is mentioned here:

https://community.atlassian.com/t5/Jira-questions/Re-Increment-Custom-Field-on-Transition/qaq-p/1390553/comment-id/613243#M613243

It seems it should work. But your value is wrong:

{{#increment}}{{issue.customfield.customfieldID}}{{/}}

This is from the post:

{{#increment}}{{issue.yourcustomfield}}{{/}}

should be issue.customfield_1000 for example. remove the first customfield and add your custom field ID.

Regards

Nathan Price
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
January 15, 2025

Hi Aaron, 

Thank you for the advice, I have adjusted format of the increment as you described, replacing the ".customfieldID}}" for "_customfieldID}}" and this is now incrementing correctly. 

Many Thanks

 

3 votes
Tessa Tuteleers
Community Champion
January 15, 2025 edited

Hey @Nathan Price , 

Welcome to the community! 

Reading up on what you already tried, this should work with a small modification. 

Some other versions that should work would be:

As an action: Edit "Field x" with smart value:

{{#increment}}{{issue.Field x}}{{/}}

{{#=}}{{issue.Field x}} + 1{{/}}

{{issue.Field x.plus(1)}}

Those should all work under 1 condition -> Field x has to be a number field. If it is not, you are trying to calculate with strings instead of numbers, that does not work. 

You have to help the system recognize that it is a number, you could do that like this: 


{{#=}}{{issue.Field x.asNumber}} + 1{{/}}

{{issue.Field x.asNumber.plus(1)}}

   

Did any of that solve your issue? 

- Tessa

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PERMISSIONS LEVEL
Product Admin
TAGS
AUG Leaders

Atlassian Community Events