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

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

This widget could not be displayed.

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
Community showcase
Published Aug 22, 2018 in Marketplace Apps

How a Marketplace app tech team is achieving gender diversity

Hello! My name is Genevieve Blanch, and I'm the Marketing Manager at RefinedWiki, creators of apps to give teams the tools to customize Atlassian platforms. Currently, 44% of the tech team at Re...

526 views 3 19
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