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 Transition parent issue based on subtask status JIRA 8

Hello,

How to make auto set up with Scrip runner if sub-task status changed from ToDo parent task gets status In Progress

JIRA 8.2.1 - Script Runner: 5.6.2.1-jira8

I tried this one:

import com.atlassian.jira.component.pico.ComponentManager;

import com.atlassian.jira.issue.comments.CommentManager;

import com.opensymphony.workflow.WorkflowContext;

import org.apache.log4j.Category;

import com.atlassian.jira.config.SubTaskManager;

import com.atlassian.jira.workflow.WorkflowTransitionUtil;

import com.atlassian.jira.workflow.WorkflowTransitionUtilImpl;

import com.atlassian.jira.util.JiraUtils;

import com.atlassian.jira.issue.MutableIssue;

 

String currentUser = ((WorkflowContext) transientVars.get("context")).getCaller();

WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class);

MutableIssue parent = issue.getParentObject() as MutableIssue

 

String originalParentStatus = parent.getStatus().getSimpleStatus().getName()

def isDevBacklogStatus = originalParentStatus in ['To Do']

 

if (isDevBacklogStatus) {

workflowTransitionUtil.setIssue(parent)

workflowTransitionUtil.setUserkey(currentUser)

workflowTransitionUtil.setAction(11)

if (workflowTransitionUtil.validate()) {

workflowTransitionUtil.progress()

}

}

 

But got an error: use ComponentManager.loadComponent(Class, Collection)

1 answer

1 accepted

0 votes
Answer accepted

Hi @Asta_Adamonytė 

JiraUtils.loadComponent is deprecated and it might be removed within further releases.

loadComponent(Class<T> componentClass)
Deprecated. 
use ComponentManager.loadComponent(Class, Collection)

See API documentation here. But it is still not removed, so you can still use it. So, it should be a warning instead of error.

Hi @Tuncay_Senturk__Snapbytes_ 

Thanks! I am totally green with Script Runner. Maybe you could write how it should be used in full script? :) 

Hi @Asta_Adamonytė 

There is nothing wrong with your script. 

I just typed it into Script console and it succeeded on transitioning the issue.

You can add some logs to your script like: log.error("trace 1") and see the logs whether it is executed normally.

Like Asta_Adamonytė likes this

Thanks! Need more time for this.

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