Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in
Deleted user
0 / 0 points
Next:
badges earned

Your Points Tracker
Challenges
Leaderboard
  • Global
  • Feed

Badge for your thoughts?

You're enrolled in our new beta rewards program. Join our group to get the inside scoop and share your feedback.

Join group
Recognition
Give the gift of kudos
You have 0 kudos available to give
Who do you want to recognize?
Why do you want to recognize them?
Kudos
Great job appreciating your peers!
Check back soon to give more kudos.

Past Kudos Given
No kudos given
You haven't given any kudos yet. Share the love above and you'll see it here.

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 to transition a subtask when another subtask is resolved. Edited

Let me explain my current situation.

I have 2 workflows defined for a Kanban Project:

  • The first one has 4 statuses (TODO, INPROGRESS, REVIEW & DEFINED), this is the main workflow for Developers to work with. When the Developer creates a Task in this project, I set up the transition so it creates 5 different sub tasks (A, B, C, D & Report), 4 of which (A, B, C, & D) follow this WF. B can't be resolved until A is, C can't be resolved until B is and so on.
  • And I have another workflow defined with 5 statuses (OPEN, A COMPLETED, B COMPLETED, C COMPLETED & D COMPLETED) for the last subtask (Report). The intention of this subtask is to report the status of the other 4 subtasks.

My question is.

How can I define a Post Function Custom Script to automatically transition the Report Subtask when the other subtasks are resolved?

Do I need to create a link between the subtasks when they are created?

I made a research in the community and didn't found a something like this

Please make it as simple (for dummies) as possible.

 

1 answer

So I got no answers but I found a solution if anybodyelse requires it:

I added the following Custom Scripted PostFunction in the transition from "REVIEW" to "DEFINED":

/**
*The script transitions the subtask "Report" when the subtask "A" transitions to Defined
*/

//Required Imports
import com.atlassian.jira.component.ComponentAccessor;
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.*;
import com.atlassian.jira.issue.MutableIssue;
import com.atlassian.jira.issue.fields.CustomField;
import com.atlassian.jira.issue.CustomFieldManager;
import org.apache.log4j.Category
import com.opensymphony.workflow.WorkflowContext;
import com.atlassian.jira.event.type.EventDispatchOption

//Variables
String currentuser = ((WorkflowContext) transientVars.get("context")).getCaller()
SubTaskManager subTaskManager = ComponentAccessor.getSubTaskManager();
if (issue.getIssueType().getId() == "55")//55 is ID for "A" subtask issue type
{
    MutableIssue parent = issue.getParentObject() as MutableIssue;
    WorkflowTransitionUtil workflowTransitionUtil = (WorkflowTransitionUtil) JiraUtils.loadComponent(WorkflowTransitionUtilImpl.class)
    Collection<Issue> subTaskList = subTaskManager.getSubTaskObjects(parent);
    Iterator<Issue> iterator = subTaskList.iterator();
    while(iterator.hasNext())
    {
        Issue subTaskObj = iterator.next();
        if (subTaskObj.getIssueType().getId() == "59" || subTaskObj.getStatus().getId() == "26")//59 is the ID for "Report" subtask issue type & 26 is the ID for the status "Open"
         {
            workflowTransitionUtil.setIssue((MutableIssue) subTaskObj)
            workflowTransitionUtil.setUserkey(currentuser)
            workflowTransitionUtil.setAction(21)//21 is the transition ID from "Open" to "A - Defined"
            workflowTransitionUtil.validate()
            workflowTransitionUtil.progress()
         }
     }

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase

The benefits of using Jira in different departments

Jira is a great tool to use across different departments. Forget that paperwork – switch to Jira and get that tasks done smoothly. Marketing Jira allows for a complete digital transformation of you...

66 views 0 3
Read article

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