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?
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)
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!
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."
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:
This community is celebrating its one-year anniversary and Atlassian co-founder Mike Cannon-Brookes has all the feels.Read more
Atlas Camp is our developer event which will take place in Barcelona, Spain from the 6th -7th of September . This is a great opportunity to meet other developers and get n...
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!
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