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

Scripted field to get "last updated by" not getting updated for comments added

achoudhary February 12, 2023

I have a script to fetch "last updated by" but it doesn't work for comments. Can you help me with the piece of code needs to be added here.

//Code 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.user.ApplicationUser


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
return user;
log.error(user.displayName.toString())

Regards,

Ankit Choudhary

1 comment

Comment

Log in or Sign up to comment
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 14, 2023

Comments do not go into the history, so you're not able to read them with the changeHistoryManager.

You'll need to use commentManager to find the latest comment on the issue, and then compare it with date you find in the change history to work out which of the last update and last comment is the later one!

TAGS
AUG Leaders

Atlassian Community Events