Transition Parent based on all subtasks being in a certain workflow state

Darren Fairweather August 23, 2017

Hi All! Newbie here!

I know someone can help :)

I have read this post....

https://community.atlassian.com/t5/JIRA-Core-questions/Script-Runner-Transition-parent-issue-based-on-subtask-status/qaq-p/63722

I'm having the same issue. My workflows for parent and subtask are different. What i'm wanting is to transition from "Validated" to "Records Requested" in the parent workflow based on its subtasks reaching a workflow state of "Passed". As mentioned the parent and the subtask have different workflows.

This was my starting code from the previous post but i've done nothing to it. Please could someone thow a hand and tell me what changes i need to make? I did read i needed....

"a script on the sub-task workflow. You can either hard-code the action ID or look it up by name from the WorkflowManager)"

 

 

import com.opensymphony.workflow.WorkflowContext;

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;

import com.atlassian.jira.component.ComponentAccessor

 

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

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

MutableIssue parent = issue.getParentObject() as MutableIssue

 

String originalParentStatus  = parent.status?.name

def isDevBacklogStatus = originalParentStatus in ['Next Up Dev', 'Backlog Dev', 'Selected for Development']

 

if (isDevBacklogStatus) {

    workflowTransitionUtil.setIssue(parent)

    workflowTransitionUtil.setUserkey(currentUser)

    workflowTransitionUtil.setAction(31)

    if (workflowTransitionUtil.validate()) {

        workflowTransitionUtil.progress()

    }        

}

 

 

 

 

Thanks in advance and hoping for a favourable reply :)

 

1 answer

0 votes
Stephen Cheesley _Adaptavist_
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 6, 2017

Hi Darren,

I think you have a couple of options here. The first option is to use a workflow transition condition. I found a post where someone else has done this exact same thing here (https://community.atlassian.com/t5/Answers-Developer-Questions/Help-with-Parent-Transitions-upon-Sub-Tasks-Transitioning/qaq-p/495747)

You might not be able to get that to work with your workflow setup (i.e. the parent task having a different workflow to the subtask, although I think it will be fine). If you struggle with that you could modify the approach slightly by using a ScriptRunner script condition instead of a sub-task blocking condition.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events