Scripted field for transition number - how to?

Hi All,

hence I am not acquinted in Groovy could you please help me? We would like to have a custom field which displays the number of reopening an issue. So by default the value will be 0 for each issue and each time the issue has been reopened from Resolved to Reopen than the value will increment by 1.

We don't have MISC workflow plugin nor JJUPIN. We only have Behaviour and Script Runner. Could you please help us?

The workflow post function method is not working for us because we need that values retrospectively.

Thanks in advance,

Rumi

1 answer

import com.atlassian.jira.ComponentManager
def componentManager = ComponentManager.getInstance()
def changeHistoryManager = componentManager.getChangeHistoryManager()
Double counter=0
changeHistoryManager.getChangeItemsForField(issue, "status").each{
 if (it.toString=="Reopened")
 {
  counter=counter+1
 }
}

return counter

You need to create new custom field of type Scripted Field and add upper code to it (from jira administration, Add-ons, Scriptrunner Script fields).

Field has parameters:

- Template: Number field
- Configured searcher: Number Searcher

Please check your status name after reopening issue and change it in script to proper value.

Suggest an answer

Log in or Sign up to answer
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Julia Dillon
Posted Tuesday in Jira

Tell us how your team runs on Jira!

Hey Atlassian Community! Today we are launching a bunch of customer stories about the amazing work teams, like Dropbox and Twilio, are doing with Jira. You can check out the stories here. The thi...

236 views 1 18
Join discussion

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