I want to copy comment from one issue to linked issue only when I add comment on screen at the time of resolving first issue. I am using custom post script.
Can you please help .how to use groovy for that
Hello,
we add some phrases to comments written during a transition in our workflows. Our biggest problem was to get the information if a comment has been written on the transition screen. With the following code you can get the information you need.
import com.atlassian.jira.component.ComponentAccessor // Manager def cm = ComponentAccessor.getCommentManager() currComments = cm.getComments(issue) if (!currComments.isEmpty()) { currComment = currComments.get(currComments.size()-1) if (issue.getUpdated() <= currComment.getUpdated()) { log.debug "There is a comment during transition." } else { log.debug "There is no comment during transition." } }
I hope this helps to solve your problem. Now you can add something to the comment or use it for whatever you like.
EDIT: I missed an important information for my answer.
You have to put this code in the post-function section of your workflow transition after the step "Add a comment to an issue if one is entered during a transition."If you just add this code, it will be added on top and then you have to move it below the step. You can't access the new comment earlier.
hey Thank you so much. It works.
actually my post function position was wrong
There is much easier way to get comment from transition screen:
transientVars.get("comment")
As of today 2019-OCT-09 it works fine as well with JIRA 8 and scriprunner v5.
Is there any way to edit the comment was made in that screen?
Hi Jorge,
The comment that was made on transition will appear under regular comment section in the JIRA issue.
If you have 'Edit Comments' permissions on Permission scheme then you would be able to edit comments.
Regards,
Vlad
An interesting question that I would like to know the answer to. I know how to get the last comment, but it isn't always the one entered on the transition.
Hi Marina,
Did you see answer from Evgeniy_Russkikh above:
There is much easier way to get comment from transition screen:transientVars.get("comment")
It looks like you're new here. Sign in or register to get started.