Automation: Epic > Tasks >Sub-tasks
Asked by Wilcor G:

I am trying to automate our monthly tasks where every 1st of the month the following will be created:

EPIC \> MMM YYYY Monthly tasks

Task \> Monthly Task 1

- Subtask 1

- Subtask 2

- Subtask 3

Task \> Monthly Task 2

- Subtask 1

- Subtask 2

- Subtask 3

I was able to create the automation where the epic is scheduled but the sub-tasks are going under the EPIC and the Tasks are created outside the epic. Below is the SS of the automation and the results:

![Screenshot 2023-07-18 at 7.01.14 PM.png](/t5/image/serverpage/image-id/269684i733B16DBAE997181/image-size/large?v=v2&px=999 "Screenshot 2023-07-18 at 7.01.14 PM.png")

Thanks!


Answers:
author: Fernando Eug?nio da Silva
body: [@Wilcor G](/t5/user/viewprofilepage/user-id/5271432) , Welcome to the Atlassian Community!

There's no easy way to explain this, but I will try to leave all steps that you need to follow to get your result.

1- Creating your Epic

* To have the current month/year in Epic Summary, you need to fill the summary with this value: **{{now.format("MMMM,YYYY")}} Monthly Tasks**
  * What this does? This will create your Epics like this: **July,2023 Monthly Tasks** and automatically the next month will be **August,2023 Monthly Tasks**
* After the action created epic, create a variable with this smartvalue: **{{createdIssue.key}}**
  * This variable will record the key for the Epic Issue and we gonna use him to set Epic Link for the tasks

![Screenshot_127.png](https://community.atlassian.com/t5/image/serverpage/image-id/269685i883DDFCD24DE5636/image-size/large?v=v2&px=999 "Screenshot_127.png")

2- Creating Tasks

* After the variable to record the Epic Key add a new action to create a task issue, you need to select the field 'Epic Link' and inside this field paste the variable you've created to record epic key

![Screenshot_128.png](https://community.atlassian.com/t5/image/serverpage/image-id/269686i47456A877D26C0CF/image-size/large?v=v2&px=999 "Screenshot_128.png")

* Add a new action to create your second task monthly and repeat the step for Epic Link field pasting the variable to get Epic Key

This is our automation untill now

![Screenshot_129.png](https://community.atlassian.com/t5/image/serverpage/image-id/269687i66CF76B941BA5EB8/image-size/large?v=v2&px=999 "Screenshot_129.png")

Just for safe reasons (delay), after the second task creation I added a branch for '**Most recently created issue** ' and inside the branch I added a **re-fetch** action

![Screenshot_130.png](https://community.atlassian.com/t5/image/serverpage/image-id/269692iEE8CAA2ECD92C294/image-size/large?v=v2&px=999 "Screenshot_130.png")

3- Creating Sub-tasks

After the Branc for Re-fetch issues add your subtasks actions. **I added 6 create sub-tasks actions**.

* For the 3 first inside the **Parent Issue** field you select this variable: **{{createdIssues.get(1).key}}**
  * This is the variable issue key for the first task created for your rule

![Screenshot_131.png](https://community.atlassian.com/t5/image/serverpage/image-id/269693iD5BA8E0A863A28B4/image-size/large?v=v2&px=999 "Screenshot_131.png")

* For the 3 last sub-tasks actions, in the **Parent Issue** field you need to add this second one variable: **{{createdIssues.get(2).key}}**
  * This is the variable issue key for the second task created for your rule

![Screenshot_132.png](https://community.atlassian.com/t5/image/serverpage/image-id/269694i0A7AC2DEF31AC7C5/image-size/large?v=v2&px=999 "Screenshot_132.png")

It works pretty well for me. You can try and back with your feedback of this answer :)

Regards,

Fernando

comments: author: Wilcor G
body: THANK YOU [@Fernando Eug?nio da Silva](/t5/user/viewprofilepage/user-id/4606715) ! It works like a charm :)


Tags: automation

cloud

jira-work-management-cloud