In ScriptRunner, I'm using a Script Field using "Date of First Transition" to track the custom field "In Progress Date" (a Date Time Range picker) when an issue first moved from 'To Do' to 'In Progress'
(our workflow is simple:
'To Do' >> 'In Progress'
'In Progress' >> 'Review' or 'To Do'
'Review' >> 'Done' or 'In Progress')
Now, the teams need to track anytime the issue moves to 'In Progress'. So not just from ToDo >> In Progress, but also from Review >> In Progress.
I have tried following these examples to use in the workflow post-function to In Progress transition, but none seem to work. I've also set this custom post function script as the first order.
Here's what I have
import com.atlassian.jira.event.type.EventDispatchOption
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.component.ComponentAccessor
import java.sql.Timestamp
import com.atlassian.jira.issue.fields.CustomField
def user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def customDateField = customFieldManager.getCustomFieldObject("In Progress Date")
def oldDate = issue.getCustomFieldValue(customDateField)
def newDate = new Date().toTimestamp()
issue.setCustomFieldValue(inProgress, newDate)
ComponentAccessor.getIssueManager().updateIssue(user, issue, EventDispatchOption.ISSUE_UPDATED, false)
Could it also be that since it's a Script Field, that I can't overwrite it with a new Date? If so, is there a way we can still keep the custom field rather than making a new one?