Help using a groovy script listener when moving an issue between projects Edited

Hi everyone,

We are deploying JIRA across several teams, and I am looking for a way to streamline the process for moving issues between projects. For example, say an issue needs to go from Project A to Project B. Currently, the lead for A has to (or should) set the Assignee to 'Unassigned,' revert the Status to 'To Do,' and then do the move procedure.

I would like to have a listener take care of changing the Assignee and the Status fields, so that the lead only has to worry about moving the issue. This will resolve problems we are having with the Project B team receiving an issue from A but being unaware as it's showing as assigned and in progress with a Project A resource.

Currently this is the code I have in the listener and there are no errors in the log, but the changes are not being saved. I somehow need to use IssueManager.UpdateIssue(), but I can't get it to work. Any help is appreciated:


import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue

IssueManager issueManager = ComponentAccessor.getIssueManager();
Issue issue = issueManager.getIssueObject(

log.warn("Event: ${event.getEventTypeId()} fired for ${event.issue} of type ${issue.getIssueType().id}")
if (issue.getIssueType().id=="10200"){
log.warn("Issue type check passed")
} else (log.warn("Issue type checking failed"))


1 answer

I'm assuming your scripted listener is already listening for the "Issue Moved" event.

Your changing the issue object but not saving it back to the database

Your best off using issue service to do this sort of thing as it will also reindex the issue for you. To do this you can use the following example:

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.event.issue.IssueEvent

def event = event as IssueEvent
def issue = event.issue

def issueService = ComponentAccessor.getIssueService()

if (issue.getIssueType().id=="10200"){

    // do transition first
    def transitionParameters = issueService.newIssueInputParameters()
    // you'll need to have a valid transition setup in your workflow for this
    // replace with your id
    def transitionId = 2
    def user = event.user

    def validationResult = issueService.validateTransition(user,, transitionId, transitionParameters)

    if (validationResult.isValid()) {
        issueService.transition(user, validationResult)
    } else {
        log.warn validationResult.errorCollection.errors

    // unassign last
    def updateParameters = issueService.newIssueInputParameters()


    validationResult = issueService.validateUpdate(user,, updateParameters)

    if (validationResult.isValid()) {
        issueService.update(user, validationResult)
    } else {
        log.warn validationResult.errorCollection.errors

A few points to note are that you should replace transitionId with the id from your workflow to transition the issue back to "To Do". You can mark the transition as hidden with a condition if you don't want users to see it.

After it's transitioned the update to unassign will be done.

Let us know how you get on with that.

Thanks Adam,  we ended up changing our approach and handling this via the workflow and our integration platform.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published Nov 27, 2018 in Portfolio for Jira

Introducing a new planning experience in Portfolio for Jira (Server/DC)

In the past, Portfolio for Jira required a high degree of detail–foresight that was unrealistic for many businesses to   have–in   order to produce a reliable long-term roadmap. We're tur...

2,969 views 19 22
Read article

Atlassian User Groups

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

Find a group

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

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you