Hi all,
in a Jira workflow, I add a transition (available on customer portal). Then, when user click on transition link, a default window appears, with possibility to add a comment.
In the workflow post function, i'would like to update this comment by adding a specific text.
how I can proceed ?
I can correctly retrieve the lastcomment, but xxx.update(mylastcommentid, "add the text", false) didn't work, or delete and then re-adding a comment not working anymore.
Is there a simple way to update latest comment?
thanks in advance.
Hi @Xavier
For your requirement, you could try something like this:-
import com.atlassian.jira.component.ComponentAccessor
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def commentManager = ComponentAccessor.commentManager
def lastComment = commentManager.getLastComment(issue)
def updateComment = """${lastComment.body}
sample update
""".toString()
commentManager.delete(lastComment)
commentManager.create(issue, loggedInUser, updateComment, false)
Please note the sample working code above is not 100% exact to your environment. Hence, you will need to modify it.
What this code does is that whenever it transitions to a specific status, for example, from To Do to In Progress, it will copy the original value from the last comment and copy the value of the last comment to another String which will also append another line of text to it. It will then remove the last comment and replace it with the updated String.
Below are a few print screens for your reference:-
1. First, an issue is created, and a comment is added to it. It is still in the To Do status.
2. Once the issue transitions to the In Progress status, the last comment is updated with the additional text as shown below:-
I hope this helps to solve your question. :)
Thank you and Kind regards,
Ram
Hi @Ram Kumar Aravindakshan _Adaptavist_
thank you for your quick feedback.
this not working on our side (from customer portal, the window with comment insertion is displaying a long time, and the unknow error message appear. Nothing in log..)
I will try to debug what happens.
But really appreciate the help.
regards
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.