Groovy Script for Linked Issue Transition

I want to write a groovy Script in which, on certain transition of issue type 1 which follows some workflow, when state changes from state 1 to state 2 then linked issue with that ticket should move its from state 1 to state 2 which follows other workflow say workflow 2.

Can any body help me out with this?

1 answer

1 accepted

You could search the forum. There have been several questions on this matter:

I'v been trying to do the same and ended up with sth. like this. Don't know if it's good but bascially transforemd existing scripts (I'm using Jamies Script Runner Plugin BTW)

// package com.test.transitionSubtask

import com.atlassian.jira.ComponentManager
import com.atlassian.jira.component.ComponentAccessor

def componentManager = componentManager.getInstance()
def issueLinkManager = componentManager.getIssueLinkManager()

import org.apache.log4j.Category
import com.atlassian.jira.issue.comments.CommentManager
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;

def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.debug "debug statements"

log.debug "Hello" 
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );

issueLinkManager.getOutwardLinks( {issueLink ->
        if ( == "Blocks") {
        log.debug ("Linktyp: " 				+
		log.debug ("Status parent: "		+
		log.debug ("ID parent: "  			+ issueLink.destinationObject.getId())
		log.debug ("Schlüssel Verlinkung: " + issueLink.destinationObject.getKey())
		log.debug ("Lösung Verlinkung: " 	+ issueLink.destinationObject.getResolutionObject().getName())

		// Nur wenn bestimmte Lösung
			if (issueLink.destinationObject.getResolutionObject().getName() == "Fixed"){
		// Transition einleiten
    		    workflowTransitionUtil.setAction (3)    // 5 == RESOLVE ISSUE

		// Add a comment so people have a clue why the child has been closed 
    		    CommentManager commentManager = (CommentManager) ComponentManager.getComponentInstanceOfType(CommentManager.class);
    		    String comment = "*Resolving* as a result of the *Resolve* action being applied to the parent.";
    		    commentManager.create(issueLink.getDestinationObject(), currentUser, comment, true);

        // validate and transition issue
else {log.debug("Hello CCCCCCCC")}

Thanks for your answer, In my case I have installed Query Custom field plugin, which is a custom field which brings issues from other issue type, so i want to first link this issue and then perform the transition so can anybody help me out.

Hi All,

Is the above script working for transitioning linked issues.




Because I also want to implement it. If it works then please anyone tell me how and where to use this groovy script.



@Darapu Rajesh Babu, you'll need a script runner plugin, the paid one will save you a lot of time with built in functionality. In the workflow editor you can add a custom script post function that runs this. It may need some tweaking but I'm about to find out and I'll post what I ended up with

Hallo @Christian Czaia,

dein Script funktioniert auch wenn zwischen zwei Tickets ein klassischer Link besteht oder nur bei einem Parent+Subtask?




you can also configure this use case with the Workflow Essentials Plugin and don't need to write a script for it.


Suggest an answer

Log in or Sign up to answer
Community showcase
Published Wednesday in Marketplace Apps

Marketplace Spotlight: Marketing apps for Confluence to keep your teams working on the same page


180 views 0 4
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