This sample script field gets the date that an issue was first transitioned through a particular action.

If it undergoes the same transition multiple times, only the first date is shown.

This can be useful for support workflows where you want to track when the customer was first responded to.

package com.onresolve.jira.groovy.test.scriptfields.scripts

import com.atlassian.jira.component.ComponentAccessor

def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def created = changeHistoryManager.getChangeItemsForField(issue, "status").find {
    it.toString == "In Progress" (1)
}?.getCreated()

def createdTime = created?.getTime()

createdTime ? new Date(createdTime) : null
1 Change to the action name you are interested in

Template

Date Time Picker

Searcher

Date Time Range picker

Have questions? Visit the Atlassian Community to connect, share, and learn with other Atlassian users and experts, including Adaptavist staff.

Ask a question about ScriptRunner for JIRA, Bitbucket Server, or Confluence.

Want to learn more? Check out courses on Adaptavist Learn, an online platform to onboard and train new users for Atlassian solutions.