Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to get assignee change history?

Samuel Lee August 27, 2014

New issue has the assignee field set to "automatic" for default value. How can I obtain the "assign date" value for usage as a value in a scriptrunner(scripted field) to track when time is changed.

2 answers

3 votes
Samuel Lee September 1, 2014

Thank Jamie. I found an example and I am able to get the assignee change history with the following scripts.

import com.atlassian.jira.issue.*
import com.atlassian.jira.issue.fields.CustomField
import com.atlassian.core.util.DateUtils 
import com.atlassian.jira.ComponentManager 
import com.atlassian.jira.issue.history.ChangeItemBean 

def componentManager = ComponentManager.getInstance();
def changeHistoryManager = componentManager.getChangeHistoryManager();

def changeItems = changeHistoryManager.getChangeItemsForField(issue, "assignee");
def firstAssigned;
if(changeItems !=null && !changeItems.isEmpty()){
	ChangeItemBean ci = (ChangeItemBean) changeItems.get(0);
	String assigneeName = ci.getFrom(); // name
	String assigneeFullName = ci.getFromString();// full name
        def assignedTime = ci.getCreated().getTime();
        firstAssigned = assignedTime;

}

Mario Ofner February 17, 2017

Is there a possibility to get the user who did the transition?

ernesto_laing@avivacanada.com
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
April 25, 2018

I also would be very interested

j2166730
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 30, 2018 edited

this is who did last update issue

def changeItems = changeHistoryManager.getChangeHistories(issue);
return changeItems.get(changeItems.size()-1).getUsername()

getUsername() Deprecated.  Use getAuthorObject() instead. Since v5.0.  

1 vote
JamieA
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 31, 2014

You need to use com.atlassian.jira.issue.changehistory.ChangeHistoryManager. Google on that, you should find some examples.

Suggest an answer

Log in or Sign up to answer
TAGS
atlassian, atlassian community, loom ai, atlassian loom ai, loom, atlassian ai, record recaps of meetings, meeting recaps, loom recaps, share meeting recaps,

Loom’s guide to great meetings 📹

Join us to learn how your team can stay fully engaged in meetings without worrying about writing everything down. Dive into Loom's newest feature, Loom AI for meetings, which automatically takes notes and tracks action items.

Register today!
AUG Leaders

Atlassian Community Events