I am using the below logic to create a scripted field for Date Closed. I cannot go back into all of our workflows and add a post function for Date Closed at this point so I am calculating it. However, some workflows allow users to re-open issues. Is there a way to capture the LAST closed date? The below code captures the 1st time the status is set to Closed.
import com.atlassian.core.util.DateUtils
import com.atlassian.jira.issue.history.ChangeItemBean
import java.text.SimpleDateFormat
import com.atlassian.jira.component.ComponentAccessor
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
String closed = changeHistoryManager.getChangeItemsForField(issue, "status").find {it.toString == "Closed"}?.getCreated()
Date formattedDate = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").parse(closed)