Has anyone done or know how to script two fields, showing the date of the last comment on an issue by a Service Desk agent and a Service Desk Customer.
So two separate fields with two dates, giving an indication of who was the last to comment and how long ago. i.e. is this something the we should be chasing up with the customer or have we let an issue slip behind.
And a working version :-)
import com.atlassian.jira.component.ComponentAccessor
def commentManager = ComponentAccessor.commentManager
def comments = commentManager.getComments(issue)
def groupManager = ComponentAccessor.getGroupManager()
def sortedComments = comments.toSorted {a, b -> b.created <=> a.created }
for (comment in sortedComments) {
if (groupManager.getGroupNamesForUser(comment.authorApplicationUser).contains("jira-servicedesk-users")) {
return comment.created
break
}
}
return null
I changed the IF statement to a NOT to get last customer comment
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @David Harkins ,
As an alternative, you can use Enhancer Plugin for Jira for this.
It has a dedicated field called Last comment Date & Last commented User and Last comment. These fields are also searchable.
Please let me know if you have further questions.
Cheers,
Gökçe
Please note that I'm a member of the Snapbytes team who developed the Enhancer Plugin for Jira.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The plugin may provide the required function, but also has a lot more features, so is probably overkill for what I need at this stage. But thank you for your suggestion.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
https://library.adaptavist.com/entity/show-last-comment-for-an-issue shows you how to get to a comment object, which you can ask for the created or updated dates, as well as the name of the author.
Note that "how long ago" is not scriptable - it's a moving target, so you'd have to be re-indexing constantly.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The how long would not be scripted in the field, but will enable queues to display issues that have not been commented on x days.
So we can get the name of the last comment author, if we need to get the last comment date by customer and the last comment date by agent, we would need to loop through all previous comments until a user match is made.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
My progress so far:
import com.atlassian.jira.component.ComponentAccessor
def commentManager = ComponentAccessor.commentManager
def comments = commentManager.getComments(issue)
log.info("Comments:" + comments.size)
if (comments) {
comments.each { comment ->
log.info("Author" + comment.authorApplicationUser)
}
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The Following:
import com.atlassian.jira.component.ComponentAccessor
def commentManager = ComponentAccessor.commentManager
def comments = commentManager.getComments(issue)
def groupManager = ComponentAccessor.getGroupManager()
//def ReturnDate = date
int check = 0
//log.info("Comments:" + comments.size)
for (comment in comments) {
log.info("Author" + comment.authorApplicationUser)
if (groupManager.getGroupNamesForUser(comment.authorApplicationUser).contains("jira-servicedesk-users")) {
log.info("Author is A Service Desk Agent")
return comment.created
break
}
}
return null
is returning the first comment where the user is a service desk agent :-(
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.