How may I increment a custom field's number on a specific transition?

Ryan Anderson March 5, 2018

Each time the transition "blah" is used I want to increment a custom field by 1. If the field's value is empty, it should become 1. If the field's value is 3 it should become 4.

The transition "blah" transitions issues to a status used by all issues, so basing the rule off the status is not possible. Each time the transition "blah" is used the issue has the resolution set to "blah" and then cleared using post-functions. This is a poor effort at keeping track of when the transition "blah" was used. The "blah" transition only exists once in-between two status' on my workflow.

The only add-on I have installed on my cloud instance of Jira is Automation for Jira and I'd like to keep it that way. Thanks in advance for your help.

2 answers

1 accepted

5 votes
Answer accepted
Nick Menere
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.
March 5, 2018

Hi Ryan,

 

You can definitely do this. To do this set up a rule to listen for an issue transition, add a Jql condition to check status of the issue (status = blah) and then add an Edit issue action.

Select the field you want (My Customfield) to increment and use the following value:

{{#increment}}{{issue.My Customfield}}{{/}}

This will increase the value every time the issue goes into that status.

 

Let us know if you have any specific problems with it or if I mis-understood the use-case.

 

Cheers,

Nick

Ryan Anderson March 8, 2018

This worked flawlessly, Nick! You're a gentleman and a scholar. Thank you.

Nick Menere
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.
March 9, 2018

Glad to have helped!

TT December 12, 2018

Hi there!

Tried to replicate on a number field, but got some problems:

 

Whenever I try to paste some part of the script it gives me an "invalid number" error.

Since it's my first time scripting in automation, I did some trouble shooting and it gives me the same error even with 

{{issue.My Customfield}}

or  

{{#increment}}4{{/}}


I'm quite puzzled because I don't have any actual idea about what is going on :(

Tiziano 

Nick Menere
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.
December 12, 2018

Hi Tiziano,

Are you able to provide a screenshot of your rule and esp. the configuration for this field.

 

Cheers,

Nick

TT December 13, 2018

Hi Nick,

I am embarassed to say that after a good head scratching I have come to the solution and I am sorry to have bothered the community: Automation for Jira it's not the same as Jira's Automation :)

I filed a request to our purchasing to get the plugin asap.

Thank you for your quick response,
Tiziano

Like Jenifer Kuntz likes this
0 votes
Jared Knowlton
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!
September 12, 2019

I am unable to get this to work.  I copied the script changed it to my field and I get, "Unable to update custom field"

Nick Menere
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.
September 16, 2019

Hey Jared,

Can you share a screenshot of your rule config and the resulting Audit Log.

 

Cheers,

Nick

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events