Forums

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

Add system field in the auto generating comment

Aravindi Amarasinghe
Contributor
September 2, 2018

Hi All, 

I have this piece of code adding auto comment in the ticket during the transition 

I want to add reporters name in the comment.  

Can somebody help? 

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, "This ticket is now closed, please check the root cause field for futher information", false)

 

1 answer

1 accepted

0 votes
Answer accepted
Fazila Ashraf
Community Champion
September 3, 2018

Hi @Aravindi Amarasinghe

 

Try this:

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.comments.CommentManager
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.*
import com.atlassian.jira.user.ApplicationUser

MutableIssue issue = (MutableIssue) issue

CommentManager comMgr = ComponentAccessor.getCommentManager()

ApplicationUser user = ComponentAccessor.getUserManager().getUserByKey("bot-account")

comMgr.create(issue,user, "This ticket is now closed, please check the root cause field for further information , Reporter name = $issue.reporter.name", false)

 

Aravindi Amarasinghe
Contributor
September 3, 2018

Hi @Fazila Ashraf

Thank you very much for your help and following modification gave me the required comment. 

Reporter name = $issue.reporter.displayName"

 

And one more thing. Do you know a way to to insert customfields as well? 

Suggest an answer

Log in or Sign up to answer