Forums

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

Adding an auto comment as a specific user

Aravindi Amarasinghe
Contributor
April 29, 2019

Hi all, 

I want to add auto comment during a transition as a specific user. 

I have this code successfully adding comment in the ticket but, as the current user.

Can you please help me to improve the code to add comment as a specific user? Eg: donotreply

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

ComponentManager componentManager = ComponentManager.getInstance()
CommentManager commentManager = componentManager.getCommentManager()

commentManager.create(issue, transientVars.context.caller, "The Auto comment", false)

 

Thank you!

 

1 answer

0 votes
Fazila Ashraf
Community Champion
April 29, 2019

@Aravindi Amarasinghe  ,

Below snippet should help

 

ApplicationUser user = ComponentAccessor.getUserManager().getUserByKey("user1")

commentManager.create(issue,user,"auto comment",false)

Suggest an answer

Log in or Sign up to answer