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.
Hi @Jorge - Jira does not provide a native mechanism to query against history so you'd need a 3rd party tool like script runner.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Judah,
I used a script field:
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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()
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.