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?
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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."
commentManager.create(issue,user,CommentText,true)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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:
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.