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
Atlassian Community Anniversary

Happy Anniversary, Atlassian Community!

This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.

Read more
Community showcase
Bridget Sauer
Published Thursday in Marketplace Apps

Calling all developers––You're invited to Atlas Camp 2018

 Atlas Camp   is our developer event which will take place in Barcelona, Spain  from the 6th -7th of   September . This is a great opportunity to meet other developers and get n...

229 views 0 6
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