Script Runner Transition parent issue based on subtask status JIRA 8

Asta Adamonytė September 16, 2019

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
Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 16, 2019

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.

Asta Adamonytė September 17, 2019

Hi @Tuncay Senturk 

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

Tuncay Senturk
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
September 17, 2019

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
Asta Adamonytė September 19, 2019

Thanks! Need more time for this.

Suggest an answer

Log in or Sign up to answer