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

Script Runner Clone Issue and Comment

Aron Felberbaum Sep 08, 2015

I'm looking to use a post function to create a linked issue using script runner, trying to figure out how I could replace the description of the new issue with last comment.

1 answer

1 accepted

3 votes
Answer accepted
JamieA Sep 08, 2015

If you are using the "clones issue" built-in post-function, you can enter the following code into the additional issue actions:

import com.atlassian.jira.component.ComponentAccessor

def commentManager = ComponentAccessor.getCommentManager()
def comments = commentManager.getComments(sourceIssue)

if (comments) {
    issue.description = comments.last().body
}
else {
    issue.description = "No comment set on source issue"
}
Aron Felberbaum Sep 09, 2015

Another Question, This transition is using a screen with the comment field, I would like to replace the description of the linked issue with this comment only when the comment is not empty.

JamieA Sep 09, 2015

get the comments in the same way as above but using "issue", not sourceIssue.

JamieA Sep 09, 2015

in a transition, the current comment is in: transientVars["comment"] - so if that's empty no comment was added

Hung Nguyen Jan 28, 2016

Jamie,

If I don't want the change the new issue's description, but copy the last comment to be a comment of the cloned one, how can we do it?

I did try to use commentManager.create( issue, comments.last().owner, comments.last().body, true)

But I got the null pointer assignment error in the log and the task failed.

Jens Kisters Oct 11, 2017

Hi,

is the "clone issue" post function still available in the current version?

I can't find it neither in the available post functions nor in the script runner docs.

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Posted in Jira Software

Demo Den Ep. 5: Meet Jira Mobile

See how to use Jira on the go! Demo Den Episode 5 is here: meet Jira Mobile with  Jira  Product Manager Rayen Magpantay.  Demo Den is in our monthly series where a Jira PM demonstrates...

428 views 1 10
Join discussion

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