Script to increment value of custom field in Post Validation Condition

I have created a Custom Field (Number) called 'Failed Count' with a default value of 0 (zero).

I want to add a Post Validator condition to the transition 'Fail', if the user selects this option from the 'In Test' status step to increment the value of the 'Fail Count' field by 1 every time it passes through this workflow path. Field is Customfield_11505 (found via looking at URL from 'Configure' option for field).

I have no idea how to code HTML, so any help appreciated.


5 answers

Using JJupin, your script is:

customfield_11505 += 1;


Thanks Radu - I will give it a go and advise if it works.

Unfortunately, it failed ...

Unable to update custom field customfield_11505 - Failed Count in issue [RELDEMO-12].

As a thought - do I need to put this code inside some HTML - something similar to this ... (as I have said, I do not know HTML or scripting code, so this is a best guess)

<!-- @@Formula: customfield_11505 += 1; : 0) -->

Also, apologies, but I have no idea what 'JJupin' means

Don't bother. It works (believe me), this is a plugin we created for easy scripting your JIRA.

So, using the 'Update Issue Custom Field' Post Validator option - in the 'Custom Field Value' - I type ... customfield_11505 +=1; - no other code around it and no other punctutation?

I believe you're talking about another plugin (JIRA Suite Utilities plugin). In that case, refer to their help. Ours do something similar, but in a completely different way.

0 votes
Tarun Sapra Community Champion Feb 25, 2014

Doing it in a post-function might be better than trying to do it in HTML/JS.

Thanks for quick response Tarun. Yes, I want to add a Post Condition, Update Issue Costom Field - Select 'Field Count' for 'Issue Custom Field' and then add the script in the 'Custom Field Value' that increments the value by 1. It is the script that I need to put in there that I don't know how to code.


this is my solution:

import com.atlassian.core.util.DateUtils
import com.atlassian.jira.ComponentManager
import com.atlassian.jira.issue.history.ChangeItemBean
def componentManager = ComponentManager.getInstance()
def changeHistoryManager = componentManager.getChangeHistoryManager()
def reopened = "1"
def resolved = "5"

def prev =""
def count = 0; 

changeHistoryManager.getChangeItemsForField (issue, "status").each {ChangeItemBean item -&gt;
 def from  = item.from;
 def to =;
 if (to.equals(reopened) &amp;&amp; resolved.equals(from))
// NOTE: doesn't show anything if less than 60 seconds
return count as Double;

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,552 views 15 21
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