This is the example code for a PostFunction to transition a linked Issue in status X to another status of the workflow. Very easy with Adaptavist Scriptrunner. See this code.

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

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
import org.apache.log4j.Category
import com.opensymphony.workflow.WorkflowContext
import com.atlassian.jira.workflow.WorkflowTransitionUtil;
import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;
import com.atlassian.jira.util.JiraUtils;
import com.atlassian.jira.issue.comments.CommentManager;
import com.atlassian.jira.issue.MutableIssue
def Category log = Category.getInstance("com.onresolve.jira.groovy.PostFunction")
log.debug "debug statements"
String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();
WorkflowTransitionUtil workflowTransitionUtil = ( WorkflowTransitionUtil ) JiraUtils.loadComponent( WorkflowTransitionUtilImpl.class );
log.debug "Original: ${issue.getId()}, ${issue.getKey()}. DETECTED " + issue.getStatusObject().getName();

List<IssueLink> allInIssueLink = issueLinkManager.getOutwardLinks(issue.getId());
for (Iterator<IssueLink> inIterator = allInIssueLink.iterator(); inIterator.hasNext();) {
IssueLink issueLink = (IssueLink);
def linkedIssue = issueLink.getDestinationObject();
log.debug "linked: ${linkedIssue.getId()}, ${linkedIssue.getKey()}. DETECTED " + linkedIssue.getStatusObject().getName();
if (linkedIssue.getStatusObject().getName().equals("STATUS_NAME")) {
log.debug "linked Content: ${linkedIssue.getId()}, ${linkedIssue.getKey()}."

//We can transition the parent ticket
log.debug "start transition"

workflowTransitionUtil.setIssue((MutableIssue) linkedIssue);
workflowTransitionUtil.setAction (XX); //Transition ID

log.debug "end transition"


Posted by:.

One thought on “New Groovy PostFunction Transition Linked Issue in STATUS X

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s