How to copy the last comment date into a Custom DateTime Field ?

Andrian Fernandopulle September 7, 2016

How to copy the last comment date into a Custom DateTime Field ? Is this even possible ?

This should trigger when ever a new comment added to an issue.

1 answer

1 accepted

1 vote
Answer accepted
Kristian Walker _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.
October 5, 2016

Hi Andrian,

This requirement can be used using the Script Fields functionality provided by the ScriptRunner Plugin.

The way to do this is to set a new Script Field called Last Comment Added and configure its searcher type to be Date Time Range Picker and ensure this field is set to appear on issues for all projects and issue types.

You should then add the script below to the Script Field

import com.atlassian.jira.component.ComponentAccessor

def comments = ComponentAccessor.getCommentManager()?.getComments(issue)

// If the current Issue has comments then get the date that the last comment was created

if (comments) {
    return comments.last()?.created as Date
}

Finally you should then ensure that the Template for the field is set to Date Time Picker like in the screenshot below and then you will see details of when the latest comment was added such as in the screenshot below.

Screen Shot 2016-10-05 at 12.17.18.png

Screen Shot 2016-10-05 at 12.18.53.png

I hope this helps

Thanks

Kristian

Andrian Fernandopulle October 5, 2016

Thank You Very much  Kristian Walker.
This is helpful 

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events