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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root

Avatar

1 badge earned

Collect

Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!

Challenges
Coins

Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.

Recognition
Ribbon

Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!

Leaderboard

Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,556,436
Community Members
 
Community Events
184
Community Groups

Date of last update on a custom field

Hello!

I need some help with grabbing the date (yyyy-mm-dd) of the last time a custom field was updated, nothing fancy just the date to display it on a dashboard for managers.

I appreciate the help.

 

1 answer

1 accepted

1 vote
Answer accepted
Mark Segall
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
Jun 06, 2022

Hi @Jorge - Jira does not provide a native mechanism to query against history so you'd need a 3rd party tool like script runner.

Thanks, I was able to pull this of with Scriptrunner

Like Judah likes this

@Jorge - How did you do this with ScriptRunner? 

Hi Judah,

I used a script field:

 

import com.atlassian.jira.component.ComponentAccessor
final String customFieldName = "Your_custom_field_name"
def changeHistoryManager = ComponentAccessor.changeHistoryManager
def changeHistory = changeHistoryManager.getChangeItemsForField(issue, customFieldName)
log.warn(changeHistory)

try{
def changedate = changeHistory.last()?.getCreated().getDateString()
log.warn(changedate)
return changedate
}
catch (Exception e){}
Like # people like this


@Jorge Thanks for sharing your code! I also used a SR Scripted Field: Date Time Range picker, Custom template (so I could manipulate the date format), I also added some logic to hide the script field if another field has no value.  

Custom Template: 

 

$datePickerFormatter.withStyle($dateTimeStyle.DATE).format($value).toString()

 

 

Script: 

 

import com.atlassian.jira.component.ComponentAccessor

// To get the Status Comments field

def statusCommentsField = ComponentAccessor.getCustomFieldManager().getCustomFieldObjectsByName('Status Comments')[0]

// To get the Status Comments field value for an issue

def statusCommentsValue = issue.getCustomFieldValue(statusCommentsField)

// To get the Status Comments field's changes

def lastComment = ComponentAccessor.getChangeHistoryManager().getChangeItemsForField(issue, 'Status Comments')

if(!statusCommentsValue){ // If Status Comments field is empty or has no value

    return null

}else{

    if(lastComment){ // If the Status Comments field has change history record(s)

        return lastComment.last().getCreated()

    }

}
 
Like # people like this

Nice work!

Like Judah likes this

Suggest an answer

Log in or Sign up to answer