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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is there any way to edit the comment was made in that screen?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi
Sorry, my questions wasn't what I wanted to know. I mean how I can edit that comment during the transitions using Script Runner.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Jorge,
There are only two options to edit a comment:
1) During transition, that means on the screen of current transition.
2) When comment already submitted and appears under regular comments section.
Did I get you right?
Regards,
Vlad
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
There is much easier way to get comment from transition screen:
transientVars.get("comment")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi Marina,
Did you see answer from Evgeniy_Russkikh above:
There is much easier way to get comment from transition screen:
transientVars.get("comment")
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.