Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Scriptrunner custom field date time: Last comment to customer for service desk projects

Ken March 23, 2021

Hi Community,

 

we would like to change our current custom field which shows the date of the last public comment to the customer. We upgraded our JIRA instance, with this the comment restrictions got removed for service desk projects and our script now shows the date and time of the last comment by us whether it's internal or not.

This is the script we used before upgrade:

import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.comments.Comment
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.security.groups.GroupManager
import com.atlassian.jira.component.ComponentAccessor
import java.util.Comparator;

def commentManager = ComponentAccessor.getCommentManager()
def groupManager = ComponentAccessor.getGroupManager()
def commentList = commentManager.getComments(issue).sort{it.getCreated()}
Collections.reverse(commentList)
for (Comment comment : commentList) {
if (comment.getRoleLevelId() == null &&
comment.getGroupLevel() == null &&
groupManager.isUserInGroup(comment.getAuthorApplicationUser(), 'service-desk-agents')) {

return comment.getCreated()
}
}
return null

 How can we change it so that only the date & time of the last comment shared with the customer is shown?

 

Thanks for the help :)

 

1 answer

1 accepted

1 vote
Answer accepted
Ravi Sagar _Sparxsys_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
March 23, 2021

Hi @Ken 

Trying to understand your question.

Do you want to display the date/time of the last comment & the comment which is shared with the customer.

First, take a look at this script to understand how to get comment visibility. For the last comment try this script.

I hope it helps.

Ravi

Ken March 23, 2021

Hi Ravi,

 

yes exactly, we want to display the date/time of the last comment which was shared with the customer. I'll take a look at the script you sent and try it out.

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
TAGS
AUG Leaders

Atlassian Community Events