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)
Hello Tammy,
Best
Tuncay
Thanks for the reply, Tuncay. I do not want to purchase a plugin for this. I thought there might be a simpler way to get the last Closed status. I just don't know the syntax to the get the last item of the list using the find. Any ideas? Or how to loop reverse?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Tammy,
Just add reverse()
changeHistoryManager.getChangeItemsForField(issue, "status").reverse().find {it.toString == "Closed"}?.getCreated()
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You're very welcome Tammy
As I mentioned before, it is wise to use status ID rather than status name.
Best
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Tuncay Seenturk_Snapbytes_
How can I implement on cloud jira about your solution? Please give details.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.