Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Scriptrunner, a script listener to log all external comment

Edited

Hi community,

I have a script which is supposed to create a log of all external comments during an event listener.

Here is my code:

import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.comments.CommentManager

import com.atlassian.jira.issue.comments.Comment

import com.atlassian.jira.issue.Issue

import com.atlassian.jira.event.issue.IssueEvent

import groovy.json.JsonSlurper

import com.onresolve.scriptrunner.runner.customisers.PluginModule

import com.onresolve.scriptrunner.runner.customisers.WithPlugin

import com.atlassian.servicedesk.api.comment.ServiceDeskCommentService

import org.apache.log4j.Logger

import org.apache.log4j.Level

import com.atlassian.jira.bc.issue.comment.property.CommentPropertyService

 

@WithPlugin('com.atlassian.servicedesk')

 

@PluginModule

ServiceDeskCommentService serviceDeskCommentService

 

final SD_PUBLIC_COMMENT = "sd.public.comment"

 

def user = ComponentAccessor.jiraAuthenticationContext.loggedInUser

def commentPropertyService = ComponentAccessor.getComponent(CommentPropertyService)

 

def commentManager = ComponentAccessor.getCommentManager()

def event = event as IssueEvent

def issueManager = ComponentAccessor.issueManager

def issue = event.getIssue()

def comment = event.getComment()

 

def isInternal = { Comment c ->

                def commentProperty = commentPropertyService.getProperty(user, c.id, SD_PUBLIC_COMMENT).getEntityProperty().getOrNull()

}

 

commentManager.getComments(issue).each {

    if (isInternal(it) == false){

        def log = Logger.getLogger("Comments")

        log.setLevel(Level.DEBUG)

 

        log.debug it.body

   }

}

 

The problem is that no log is being created even if the script work without error.

Is there a problem with the script?

 

Best regards,

Jason Li

2 answers

0 votes
Daniel Ebers Community Leader Feb 03, 2021

Hi @Kristin Lyons

do I understand you basically right that it would suffice to have the whole history of external comments listed in a reply that goes out to the customer BUT not only the last one?

If this is understood correctly voting for the following Suggestions might be a good idea to show it is of interest to your team:

https://jira.atlassian.com/browse/JSDSERVER-5228

Regards,
Daniel

I don't have an answer for you but I'm curious what the use case is for this.

Hi Kristin Lyons,

First of all, I excuse myself for wrong wording I used. I mean external comment rather than internal.

Second, the case scenario is that our client do not want to use portal and use email request only. In this situation, they need to provide their customer of all external comments which the latter create.

Unfortunately, JSM only provide the last external comment of the ticket when replying by email and this is an issue for our client.

Hope this clarified the case.

Best regards

Thanks for the use case.  Is there a specific reason why the client does not want to use the portal?  Sorry that this is not answering your question directly but maybe we can figure out another way to get this to work.

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira Service Management

Security Advisory for Jira Service Management

On October 20, 2021, Atlassian published a security advisory for Jira Service Management. The full advisory is available at this link.  We've seen a number of questions already asking for...

126 views 0 1
Read article

Community Events

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

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you