Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

How to auto create "Issues in Epic" tasks

A.M.
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
November 30, 2023

I was hoping someone could direct me in how I would be able to auto-generate "Issues in Epic" when an Epic is created in a certain project. When an Epic task is created in Project "Cupcake" we want four tasks to be created under it - A,B,C,D.

B blocks A.
C blocks D.
D blocks B.

We want the name of the Epic to be included in each of the issue types. So if the Epic is Red Velvet we want the Issues in Epic to be "Red Velvet - A", "Red Velvet - B" etc.

Would this be a Scriptrunner listener, post function, something else? I can't script and using the clone and link post function isn't fulfilling the request properly.

2 answers

0 votes
Bobby Bailey
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.
December 1, 2023

Hi @A_M_ , 

 

The functionality you need to create would be a listener. You would create a listener that listens for the 'Issue create' event in your specific project. 

General rule of thumb, is that if your rule  starts with the condition 'When X happens I want Y', then Listeners is the feature you want (unless X is moving to a status, in which case you want Post functions) 

Now that we have the Listener conditions set up, we need to access the issue to get the issue type, and if it is an Epic, the Epic Name of the issue. We can select the little blue '?' at the bottom right of the screen to get context available, which shows us this;

ListenerContext.png

So, we can access the issue from the event with the following line: 

 

def curIssue = event.issue
And details of the issue, specifically type and Epic Name like so:

def issueType = curIssue.issueType.id

if(issueType == '10000'){

    def issueEpicName = curIssue.epicName

}


Now, we have a script that will execute when an issue is created in a specific project, and the first part of our code gets the created issue, checks to see if it is an Epic and if so, get the Epic Name. 

Last part is to create the tasks. Just to be clear, I am not sure if you meant Tasks or Sub-tasks, so I will cover both, but both are created using the information found here: https://docs.adaptavist.com/sr4js/latest/hapi/create-issues

I have written out the full script here, with comments, but will include them here: 

https://bitbucket.org/Adaptavist/workspace/snippets/q7XrnB

If creating Subtasks, we can use the HAPI createSubTask function to create sub-tasks for the originally created issue

 

If creating normal tasks, we use HAPI's Issues.create functionality to create the new Task, and then link to the original created Epic using relates to (here you will want to choose own link type).

This listener will cover your needs. Let me know if this helps!

Kind regards, 

Bobby

 

0 votes
Ste Wright
Community Champion
November 30, 2023

Hi @A_M_ 

Whilst likely possible using Scriptrunner - do you have Automation within your instance?

This native feature could be used to do this as an alternative.

Ste

Suggest an answer

Log in or Sign up to answer