I have one custom field named "Data", and the values are acb1, abc2, and abc3. This field is editable on the Edit screen.
Requriment- I want to check how many issues(issue count- more than 100) have been moved from abc1 to acb2 or abc3, and how many issues have moved from abc2 to abc3 from 1st June to the current date. With the help of Scriptrunner.
For your requirement you can try something like this:-
import com.adaptavist.hapi.jira.projects.Projects
import com.atlassian.jira.component.ComponentAccessor
def changeHistoryManager = ComponentAccessor.changeHistoryManager
def issueManager = ComponentAccessor.issueManager
def project = Projects.getByKey('MOCK')
def issues = issueManager.getIssueObjects(issueManager.getIssueIdsForProject(project.id))
def mailTypeName = 'Mail Type'
def resultMap = [:] as Map<String,Long>
issues.each {
def changeHistories = changeHistoryManager.getChangeHistories(it)
def changeOptions = []
changeHistories.collect { changeHistory ->
def result = changeHistory.changeItemBeans.find {
it.field == mailTypeName
}
if (result && result['toString']) {
changeOptions << result['toString'].toString()
}
}
if (changeOptions.size() >= 3) {
resultMap.put(it.key, changeOptions.size() as Long)
}
}
log.warn "=======>>>Total issue changed: ${resultMap.size()}"
Please note the sample working code above is not 100% exact to your environment. Hence, you will need to modify it accordingly.
Below is a screenshot of the configuration:-
I hope this helps to solve your question. :-)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.