I am trying to implement a scripted field which will calculate time between issue created and first comment added to it. can someone please help with the script. I am not sure how to capture comment time in script.
I'm not sure about ScriptRunner, but using JMCF, you would write something like this:
return new Date().time - issue.get("comment").first().created.time
which would return a number of milliseconds.
Thank you David!
I have used the following code :
def commentManager = ComponentAccessor.getCommentManager()
def comments = commentManager.getComments(issue)
((comments.created.getTime() - issue.getCreated().getTime()) /1000)as Long)
It is giving me the desired result. please suggest if your one is more optimized? i can use that.
That script looks fine for scriptrunner. The only thing is you will get an error if there are no comments.
You could use the following if you wanted to display the time elapsed so far:
def comments = ComponentAccessor.commentManager.getComments(issue)
def endTime = new Date().time
endTime = comments.first().created.time
((endTime - issue.created.time )/1000) as Long
Or make a small adjustment to return null when there are no comments.
It’s very important to have access to the workflow process from anywhere. Especially if you manage the work of others. There is no difference whether you’re out of office, or drive a ca...
Connect with like-minded Atlassian users at free events near you!Find an event
Connect with like-minded Atlassian users at free events near you!
Unfortunately there are no Community Events near you at the moment.Host an event