Updating a custom field by +1 everytime issue is reopened


I am using behaviour plugin to update value of a custom field everytime a issue is reopened.. I am using the below code but no luck!!..Can anyone pls help

<config use-validator-plugin="false" name="Reopen Counter behaviour" description="" guideWorkflow="Test">

  <field id="customfield_12051" required="null" readonly="false" hidden="false" validator-class="" validator-script="import com.onresolve.jira.groovy.user.FormField

FormField formUserField = getFieldByName("ReopenCounter")

formUserField.setFormValue(Integer.valueOf(formUserField.getFormValue()) + 1)
" validator-method="">

    <when action="3"/>



I am new to using this plugin so pls enlighten on mistakes if any or if I am missing something!!

3 answers

1 accepted


I know that this isn't really answering your question but I think you're better off using for example the script runner to inject a script which is increasing the field value by one as a post-function.


You don't need to update the field in real-time and that's the benefit of the behaviours plugin...

You could also think of the Misc Workflow Extensions Addon:


I know that it's not free anymore but if offers all kinds of useful post-functions such as "increasing the value of a field":




Exactly what Christian said. If you don't need to use the behaviours plugin and you can do everything server-side, then do it. Use behaviours when you want dynamic form behaviour, or you want the user to be able to override the suggestion.

Thanks Christain, I used script runner plugin for this and it worked

Hi When you are updating the custom field is it for that particular ticket or for ever for that project.


I even need to decrease the custom field value but next when anyone logs in he should see the decreased value. How can I achieve it?

Projects don't have fields, so it's for the issue.

When a value is changed via a script or behaviour, you will see it the next time you land on or refresh a page

Hi Nic,


Can you guide me how can I achieve it. I was using javascript to add a value in the custom field but when I refresh the page the custom field does not have that value. It contains only for that issue. How can I change the value in the custom field so that it exists even after refresh. Kindly guide me to achieve it.

I wouldn't do it with Javascript, that way madness lies.  Use a proper field and a bit of code to change the value.

What do you have in the way of scripting add-ons?

Issue issue  = issue

String field = "customfield_12250"
CustomFieldManager customFieldManager = componentManager.getCustomFieldManager()

CustomField fieldobj = customFieldManager.getCustomFieldObject(field)

counter = issue.getCustomFieldValue(fieldobj).floatValue()
issue.setCustomFieldValue(fieldobj, counter)

Some minor updates to Bhupesh's code above, updating it for v6.2.7, and possibly higher:



import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.MutableIssue
import com.atlassian.jira.issue.fields.CustomField

MutableIssue issue = issue

CustomField fieldobj = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectByName("myFieldName")

counter = (float) issue.getCustomFieldValue(fieldobj)
issue.setCustomFieldValue(fieldobj, counter)



Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Jira

Make your Atlassian Cloud products more secure: our NEW admin security guide

Hey admins! I’m Dave, Principal Product Manager here at Atlassian working on our cloud platform and security products. Cloud security is a moving target. As you adopt more products, employees consta...

45 views 0 2
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you