Add comment as defined user

I want to post comments on fast track transitions. I would like the comments to show as added by the system as opposed to the submitter/creator.

Can a comment be added but also define the user creating the comment as well?

2 answers

1 accepted

0 votes
Accepted answer

Hi Cary,

Yes, I believe this should be possible. The CommentManager has several different methods for creating a comment. 

Comment create(Issue issue,
               ApplicationUser author,
               String body,
               String groupLevel,
               Long roleLevelId,
               boolean dispatchEvent)

It allows you to specify the issue, the author, the text of the comment, and a bunch of other things.

HI Joshua - Thank you for the response.

I found the same and did try it out. Below is what I ended up with. I think what I am struggling most with is application of these functions I field; my own lack of technical knowledge. Can you fill in the gaps to what I am doing wrong? I think I defined the issue properly, but how do I define the author properly?


Ultimately I wont all comments like this added as a generic user. User's full Name is "Service Desk Assistant", ID is SD.Assist.

def issue = event.issue

Comment create(issue,author,"This ticket automatically approved due to the permissions of the submitter.", true)

Hi Joshua,


I think I may have made the necessary modifications in order to make this work. If you could review the below and possibly provide any best practices, or point out any unnecessary steps, this would be greatly appreciated!


New Action:

import com.atlassian.jira.component.ComponentAccessor

def commentManager = ComponentAccessor.getCommentManager()
def issue = event.issue
def userManager = ComponentAccessor.getUserManager()
String UserName = "SD.Assist"
def user = userManager.getUserByName(UserName)
String CommentText = "Comment to be applied."


Hi Cary,

Great work! That script looks like it should work fine in a listener. The only thing you might look into changing is using getUserByKey() instead of getUserByName(). Getting a user by their key will make sure you always have the correct user, because user keys are unique. More than one user can have the same username, as they are not unique. I seriously doubt this will make a difference in your case, but just thought I'd let you know.

Have you tested the script out yet? Seems to be working in my instance:

Screen Shot 2017-11-27 at 2.36.58 PM.png

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 29, 2018 in Marketplace Apps

How to set up an incident workflow from the VP of Engineering at Sentry

Hey Atlassian community, I help lead engineering at Sentry, an open-source error-tracking and monitoring tool that integrates with Jira. We started using Jira Software Cloud internally last year, a...

1,700 views 3 11
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