Forums

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

Find who assigned an issue using ChangeHistoryManager

Michael Schultz January 24, 2019

issues.each { issue ->
def assignee = issue.getAssignee()
def reporter = issue.getReporter()
def isAssigned = assignee != null
def isAssignedToTenable = assignee?.getUsername() == QUERY_USER_NAME // <-- Constant User
def assigneeChanges = changeHistoryManager.getChangeItemsForField(issue, "assignee")
def postCreationNonTenableAssignment = assigneeChanges.find{it.getTo() != null && it.getTo() != QUERY_USER_NAME}
def assignmentTime = postCreationNonTenableAssignment?.getCreated()

if (assigneeChanges.size() == 0) { // <-- Has not had an assignment change.

-- Do things --

else { // <-- Has had an assignment change.

def firstAssigneeChange = assigneeChanges[0]

if (!isAssignedToTenable && /* "actor = Sec-Eng team" --> How do I find the assignment actors? */ ) {

}
 

 Anyone know how I can find the assignment actors for each issue? I can see who it's assigned to and from easily. But I'm missing something when it comes to finding the user whom initiated the action.

1 answer

1 accepted

1 vote
Answer accepted
Rambabu Patina _Appfire_
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.
January 25, 2019

Hi @Michael Schultz,

Method getChangeItemsForField will return the type List<ChangeItemBean> and from the ChangeItemBean type you cannot retrieve the author name who performed the action.

For that you may use the method changeHistoryManager.getChangeHistories(Issue issue) and filter the history for assignee field change and then use changeHistory.getAuthorKey().

I have not tried it but may it help you.

Thanks,
Ram.

Suggest an answer

Log in or Sign up to answer