very easy, the trick is access to the class changeHistoryManager.

Try this example in the “Adaptavist Scriptrunner” Script Console view. Just put the ID of the ticket and run the code. You will see always the last change of the issue.

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager

IssueManager issueManager = ComponentAccessor.getIssueManager();
def issue = issueManager.getIssueObject("JIRA-1234");
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeItems = changeHistoryManager.getAllChangeItems(issue)

if (changeItems?.size() > 0) {
    def userUtil = ComponentAccessor.getUserUtil()
    def last_change = changeItems.sort(false).last()
    def text = "LAST MODIFIED FIELD:"+ last_change["field"]+ "; FROM VALUE:"+ last_change["fromValue"] + "; TO VALUE:"+ last_change["toValue"]
    return text;
} else {
     return "NO CHANGES"
}
Posted by:.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s