Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to get Comment from screen on transition using groovy script

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

4 answers

1 accepted

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

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

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. 

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

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.

Hi Marina,

Did you see answer from Evgeniy_Russkikh above:

There is much easier way to get comment from transition screen:

transientVars.get("comment")

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.

Suggest an answer

Log in or Sign up to answer
TAGS

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you