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

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

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

Thank You Very much  Kristian Walker.
This is helpful 

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Published Sunday in Agility

You asked for it, so we delivered: images on issues have arrived

A picture tells a thousand words. And agility boards have just released their latest feature: cover images on issues – so now your board can tell a story at first glance. Upload attachmen...

1,011 views 3 12
Read article

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you