Cloning Sub-tasks for a lookup issue (story)

Aaron Eden October 18, 2024

I have template stories with sub-tasks on them for standardized work.    When any new story is created I'd like to match it's title to our template stories.  If the title matches then I'd like to clone the sub-tasks from the template story onto the newly created story.

For some reason the "For Sub-tasks" portion of my automation appears to be running against the triggering story rather than the Lookup story. 

Any help would be much appreciated:

Screenshot 2024-10-18 at 11.37.46 AM.pngScreenshot 2024-10-18 at 11.37.53 AM.pngScreenshot 2024-10-18 at 11.38.41 AM.png

1 answer

1 accepted

3 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.
October 18, 2024

Hi @Aaron Eden -- Welcome to the Atlassian Community!

To which issue are you setting the parent of the new subtasks?  From what you describe, it seems the parent is not selected or is setting to the trigger issue.

If you want it to be a specific one, that key will need to be provided in the Clone Issue action.

Kind regards,
Bill

Aaron Eden October 18, 2024

Ahh yes, I should have included that detail and thanks for the speedy reply.  The Clone Issue task doesn't ever seem to execute.  It always says there are no Sub-tasks, but I've confirmed my templates include sub-tasks.

Screenshot 2024-10-18 at 11.47.02 AM.png

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.
October 18, 2024

Ah...it is trying to branch over subtasks of the trigger issue, but you want them to be from the source issue found by the lookup.

In that case, change your branch type to JQL.  If that variable is the key to your template story, the branch JQL could be this:

parent = {{templateStory}} AND issueType = "Sub-task"

Please check that to confirm the types and variable match your site.

Like # people like this
Trudy Claspill
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
October 18, 2024

EDIT: 

@Bill Sheboy shared the same answer faster than me ;-)

I'll just leave mine here for posterity.

 

Hello @Aaron Eden 

Welcome to the Atlassian community.

What are the details of the two Create Variable actions?

One problem with your rule is that at the point you are using the For Subtasks branch, the focus of the rule is still the triggering issue. You have not changed the focus of the rule to the template issue. Subsequently the rule can't find the subtasks to Clone. This is supported by the message in the log file that says "No related issues could be found."

Additionally this condition:

Screenshot 2024-10-18 at 11.56.25 AM.png

...is executing against the trigger issue. Subsequently the criteria

summary ~ "\"{{issue.summary}}\""

...is pointless because of course the Summary of the trigger issue will match {{issue.summary}}

I think what you need to do is use that JQL in a Lookup Issues action instead to find the template issue:

project=ICSAUTO and issuetype=Story and summary~"\"{{issue.summary}}\"" and key != {{issue.key}}

The Lookup will then find an other issue in the project that has a matching summary, besides the issue that was just created.

However, is it possible that this template will be used multiple times? Might there be other issues also in the project besides the newly created issue and the template that have the same Summary? If so, you might need to add more criteria to the JQL to find just the template issue.

To ensure you have found one and only one matching issue you should add a Smart Value Condition after the Lookup Issues action to check the following:

Smart value: {{lookupIssues.size|0}}
condition: equals
Value: 1

That will ensure you have found just one isue.

After that you can use a For Related Issues: JQL branch to iterate over the subtasks of the template issue with a JQL similar to this:

parent={{lookupIssues.first.key}}

That will iterate over all the child issues of the issue found by the Lookup Issues action.

Within that branch you would execute your Clone action and set the parent to Trigger Issue. You would not reference the {{lookupIssues}} object within the Clone action.

Like # people like this
Aaron Eden October 21, 2024

Thank you both, your suggestions did the trick!

Like Bill Sheboy likes this

Suggest an answer

Log in or Sign up to answer