Forums

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

Automation to link sub-tasks within an Epic

daniel_jones September 9, 2025

Hello, 
I have need to link many sub-tasks as "is dependent on" both within a story and across several stories within a single Epic.  Currently I have automation to create all of the stories and sub-tasks when a certain Epic is created.  However many of the sub-tasks need to be linked.

I have solved it by once the automation to create the stories and sub-tasks is complete, then doing JQL search by Summary to find each sub-task, creating a variable to hold each sub-task key and linking them.  But there are about 40 sub-tasks and the automation seems cumbersome and takes a while to run.

I was wondering if there is a more efficient way to do this? Maybe with {{lookupIssues}}? to find the sub-tasks all at once?

Or would this be better as a Groovy script in Scriptrunner?

 

Thanks in advance!

2 answers

1 accepted

2 votes
Answer accepted
Bill Sheboy
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.
September 9, 2025

Hi @daniel_jones 

Without seeing the specifics of the rule which creates the subtasks...

You might be able to use the Lookup Work Items action or the Story's smart value {{issue.subtasks}} to do this, and it depends upon two things:

  • How long is the current rule?
    • You describe creating 40 subtasks.  Unless those are all added in one step with the Create Sub-tasks action, your rule likely has 40 Create Issue actions.  In that case, the rule could not branch to each subtask as it would exceed the maximum rule length.
  • How do you determine the dependencies between the subtasks?  Is it only by the Summary?
    • If it is only by the summary, the rule could use list filtering with the lookup result or the subtasks smart value to find the correct key for linking.  If the determination is more complex, branching on JQL would be required, as you are currently trying.

 

Based on the 40 subtasks count, I expect any approach with a single rule will be difficult.  Thus, I recommend investigating the external scripting approach.

 

Kind regards,
Bill

daniel_jones September 9, 2025

Hi @Bill Sheboy ,

First thank you.  I see your name all over these boards and I appreciate you taking time on my question.

We have a set of regular work that requires and Epic, several stories, and many sub-tasks within the stories.  The Epic always has specific text in the Summary, i.e., ABCDEF.

I have automation that triggers when an Epic with that text in the summary is created which kicks off an automation to make the 6 stories within that Epic.  The stories also always have specific text in their summary as well. 

So I have 6 other automations that kick of when a story with specific text in its summary is created which then creates the sub-tasks within those stories.

All of the above works and I have a workaround I mentioned earlier for the linking-using JQL in the automation to find two sub-tasks and link them.  There are between 9 and 15 sub-tasks in each story.  Currently we use Summary text to find the sub-tasks as they are always the same text, but if there is a different way to do it I would be pleased to hear it.

The whole process above takes 2-2.5 min to complete.  Maybe I am just expecting too much but it just seems like there should be a more elegant way to solve this. 

Bill Sheboy
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.
September 9, 2025

Thanks for that information, @daniel_jones as it narrows down the scope a bit.

And, based on the question tags I am assuming you are using Jira Data Center.  If not, please let me know.

 

For a single story rule, which adds a lot of subtasks, the issue creation will take a bit of time...and adding the links afterwards will take even more.  You can reduce some of the time to find the subtasks to link them in several ways:

  1. If you are adding subtask with Create Work Item, you may save their keys for use later with the Create Variable action and the smart value {{createdIssue.key}} for the most recently created one.  Then later use those variables in linking.
  2. If you add all the subtask at once with a single, Create Subtasks action, using smart value, list filtering will be faster than JQL branches or a lookup: https://community.atlassian.com/forums/Automation-articles/Filtering-smart-value-lists/ba-p/1827588

 

For that second option, assuming the rule uses a Re-fetch Issue Data after adding the subtasks, the key for the subtask with a summary containing "CODE REVIEW" could be this:

{{#triggerIssue.subtasks}}{{#if(summary.match("^.*(CODE REVIEW).*").length.gt(0))}}{{key}}{{/}}{{/}}

I recommend testing with some example issues, perhaps only writing to the audit log without linking initially.

 

Another option for scenarios like this is to investigate marketplace apps which have additional features to support cloning / templated issue scenarios.

daniel_jones September 10, 2025

@Bill Sheboy 

Yes I am on Data Center, V10.3.9

I use the Create Issue action as I have need to have the sub-task inherit a few fields from the parent story.

For the {{createdIssue.key}}-this seems like it would work for linking a sub-task the previous sub-task most recently created, but not other ones in other stories.  Am I correct? or can these be persistent? I thought variables were only in scope for their immediate action?

Marketplace is not an option as no budget for them :(

Thank you again for your help.

 

Bill Sheboy
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.
September 10, 2025

Hi @daniel_jones -- Smart values (including created variables) scope depend upon where they exist and where they were created in the rule.  Please see this article I wrote on the topic to learn more.  For your scenario, as long as any values are created outside of branches, you should be okay.

More specifically, for the singular {{createdIssue}} one, that is for the most recently created issue.  There is a plural {{createdIssues}} smart value that is a list of all the created ones, but that assumes you know the creation order...and that is unknown if you are using the Create Subtasks action.

 

Again, I suggest trying this with some test issues and writing values to the audit log.  If you run into challenges, please post images of your complete rule and the audit log as that will help diagnose any symptoms.  Thanks!

daniel_jones September 10, 2025

Thank you @Bill Sheboy 

we have a test instance where I can try out your suggestions.  if you are interested I will post results back here.  Otherwise, have a wonderful day and keep helping all us JIRA master wanna bees

0 votes
Matteo Vecchiato
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.
September 9, 2025

Suggest an answer

Log in or Sign up to answer