How can I automate the creation of Sub-tasks with a list of outgoing and ongoing dependencies?
Asked by Mourad Siala:

Hi all,

I am searching for a solution to automate the following:

I have a Task, let?s name it X. When I click on the automated button, JIRA creates a predefined list of Sub-tasks for X and creates as well a predefined list of (non-ASAP) outgoing and incoming dependencies between them.

Is that doable?


Answers:
author: Arkadiusz Inglot
body: Hello

*as well a predefined list of (non-ASAP) outgoing and incoming dependencies between them.*

What exactly do You mean by that?

1. What the dependencied are exactly in terms of jira objects?

2. What are Incoming and outgoing ones? (linked issues with specific relations?)

comments: author: Mourad Siala
body: Hi Arkadiuz,

Thanks for reaching out.

The dependencies must be issue links from type: "has to be done before".

This means: For parent task X, let?s say I create 3 Sub-tasks A, B and C. I want the automation to create as well links between A, B and C as follows:

* C can begin only if B is done.
* B can begin only if A is done.

Please let me know whether this is still unclear.


author: Arkadiusz Inglot
body: Hello

It can be quite complicated, but I have no other solution for that. This may not be a optimal way.

Assumptions:

1. Your main task X is issuetype=Task
2. New Custom Field named: "startIndex" (number field)
3. Via manual automation (or any other trigger) you create 3 subtasks (issueType=Sub-task) linked to main task - I assume you will handle that on your own.
   1. When each sub-task is created assign them an index:
      1. Sub-taskA: startIndex = 1
      2. Sub-taskB: startIndex = 2
      3. Sub-taskC: startIndex = 3
   2. You can either create them manually "3 times" in automation rule with difefrent value or use some variables for that. Its up to you.
   3. Each subtask will have initial status as in above example, lets say: OPEN

Possible solution:

1. Prepare specified workflow for issueType=Sub-Task:
   1. OPEN (statusCategory = OPEN/gray)
   2. IN PROGRESS (statusCategory = IN PROGRESS/blue)
   3. DONE (statusCategory = DONE/green)
2. On transition OPEN-IN PROGRESS set the conditions (edit workflow \> edit transition \> conditions)
   1. Choose: "Value Field"
      1. Field: startIndex
      2. Condition: =
      3. Value: 1
      4. Comparison: Number
3. Prepare automation rule in project:
   1. Trigger: transition to: DONE
   2. GetParentIssueKey \<- this may be tricky. If you dont have a custom field having a parent issue I'd create one to contain a parent issuekey.
   3. if
      1. (isueType = Sub-Task) AND
      2. (startIndex is not empty)
   4. Advanced branching:
      1. For all linked issues in PARENT ISSUEKEY (as I said, this may be tricky)
      2. Edit issue:
         1. field: startIndex
         2. value: {{issue.startIndex.plus(-1)}}

Explanation:

You set value for each task according to your hierarchy and dependency.

In this case:

C can be started after B is done

B can be started after A is done.

So: A -\> B -\> C

You can change status only if condition is set, it means whenever your startIndex is 1 in this subtask.

After you finish your first subtask, yuo lower each index by 1, so:

1 becomes 0 (0 does nothing)

2 becomes 1 (it will be the task you have to start now)

3 becomes 2 (2 needs to be lowered to 1 in order to start this task).

tricky part here is triggering the rule from sub-task, pointing back to parent and editing subtask again. It can be done via another automation or by some advanced branching.

This is written in some kind of pseudocode, I dont have a time for setting proper automation rule and provide you a screen, however this may be helpful a bit.


author: Mourad Siala
body: Hi Arkadiuz,

Thanks a lot for the effort you put in that answer.

I will have a look at it and come back to you if there are unclarities, if that?s okay for you.

Regards