how to update a comment inside of jira with Plugin?


I need to update a comment,

I can get the comment id and author.

Just need to update the comment body with plugin.

Which class should i use?

I have tried CommentManager.Update().

But i can not find how to update the comment body.

void update(Comment comment,
            boolean dispatchEvent)
Persists the updated comment.
comment - to update
dispatchEvent - if true then an event of type EventType.ISSUE_COMMENT_EDITED_ID will be dispatched and any notifications listening for that event will be triggered. If false no event will be dispatched.
IllegalArgumentException - if comment passed in is null or its id is null

1 answer

1 accepted

1 vote
Accepted answer

I have had a look in the JIRA sources and you need to get a MutableComment in the first place. Note that getCommentById returns a Comment, but under the hood, there is actually a MutableComment). You can setBody with this interface. The rest is simple, as you have already found out the update method in CommentManager.

Thanks so much,

I will try it.

HI Silviu,

I can see the mutableComment description says:

Represents a comment's in JIRA. After calling any 'setter' method, you will need to call CommentService.update(com.atlassian.jira.user.ApplicationUser, com.atlassian.jira.issue.comments.MutableComment, boolean, com.atlassian.jira.util.ErrorCollection) which does permission checking or CommentManager.update(com.atlassian.jira.issue.comments.Comment, boolean) which will just store the provided object, to persist the change to the database.

Should i use commentService or CommentManager to update comment?

What the different between them?

If i want to use CommentService to update the comment, how to get the ErrorCollection instance?


CommentService uses CommentManager under the hood. If you want, you can use CommentService to also check for permissions, but I think you will only need CommentManager.
As for ErrorCollection, here is how JIRA does:

SimpleErrorCollection errorCollection = new SimpleErrorCollection();

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,711 views 17 21
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