Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

How to get Last updated user details

Ash
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.
May 31, 2018

Hi ,

 

I'm trying to get last updated user Full name using this below,

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.user.ApplicationUsers
def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def customFieldManager = ComponentAccessor.getCustomFieldManager()
def changeHistoryManager = ComponentAccessor.getChangeHistoryManager()
def changeItems = changeHistoryManager.getAllChangeItems(issue)

if (changeItems?.size() > 0) {
def userUtil = ComponentAccessor.getUserUtil()
def userkey = changeItems.sort(false).last().getUserKey()
//return userkey.getUser(userkey)
} else {
null
}

 

Is there anyway we can get Display name instead of username?

 

TIA!!

1 answer

1 accepted

Suggest an answer

Log in or Sign up to answer
0 votes
Answer accepted
Roland Holban (Adaptavist)
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.
June 4, 2018
import com.atlassian.jira.component.ComponentAccessor

def changeHistoryManager = ComponentAccessor.changeHistoryManager
def userManager = ComponentAccessor.userManager

def changes = changeHistoryManager.getAllChangeItems(issue)

def userKey = changes.sort(false).last().userKey
def user = userManager.getUserByKey(userKey)

def name = user.displayName
Ash
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.
June 4, 2018

Thank you.

TAGS
AUG Leaders

Atlassian Community Events