For eg -
When status is moved from open to In progress,should get the first date when its moved to In progress using a Scripted field
Hi, @rajeswari saravanan
Try this:
import com.atlassian.jira.component.ComponentAccessorimport com.atlassian.jira.issue.Issueimport com.atlassian.jira.issue.MutableIssueimport com.atlassian.jira.issue.changehistory.ChangeHistoryimport com.atlassian.jira.issue.changehistory.ChangeHistoryManagerimport java.sql.TimestampChangeHistoryManager changeHistoryManager = ComponentAccessor.getChangeHistoryManager()String fieldName = "Status"String statusName = "In Progress"Issue issue = issue as IssueList<ChangeHistory> allChanges = changeHistoryManager.getChangeHistories(issue)List<ChangeHistory> cfChanges = []Timestamp firstChange = nullallChanges.each { ChangeHistory change -> if (fieldName.toLowerCase() == change.getChangeItemBeans().field[0].toLowerCase()) { cfChanges.add(change) }}if (cfChanges) {// Additional sorting by date cfChanges = cfChanges.sort { it.getTimePerformed()} firstChange = cfChanges.findAll { it.getChangeItemBeans().toString.first() == statusName}.first().timePerformed}return firstChange
Thanks for your help @Evgenii .Its working as expected 👍🏻
It looks like you're new here. Sign in or register to get started.