Hi Team,
We have a scriptrunner listener to capture the date field when a last commented by assignee, the field date is updating when the ticket assignee is adding the comment, and same date and time adding to the "Assignee Last Comment Date" field , but its not updating when we are adding the comment to the ticket transitioning from one status to another status, is there anything we need add to the script or any oder was missed in this listener ?
import java.text.SimpleDateFormat
def issue = event.issue
def simpleDateFormat = new SimpleDateFormat('dd/MMM/yy h:mm a')
if (issue.comments && issue.comments.last() && issue.assignee) { // Check for null values
def lastComment = issue.comments.last()
if (lastComment.authorApplicationUser == issue.assignee) {
try {
issue.update {
setCustomFieldValue('Assignee Last Comment Date', simpleDateFormat.format(lastComment.updated)) // Replace with custom field ID or name
}
log.info("Assignee Last Comment Date updated successfully.") // Informative log message
} catch (Exception e) {
log.error("Error updating custom field: ${e.message}") // Log errors
}
}
} else {
log.debug("No comments or assignee found.") // Debug log for missing data
}