Clone subtasks with Jira automation?

Hoang Lo March 9, 2020

Hi,
Is it possible to clone task and subtasks with Jira automation?
https://support.atlassian.com/jira-software-cloud/docs/move-an-issue-with-automation/

2 answers

1 accepted

1 vote
Answer accepted
Angélica Luz
Atlassian Team
Atlassian Team members are employees working across the company in a wide variety of roles.
March 11, 2020

Hello Hoang,

Welcome to Atlassian Community!

Searching using the details you provided, I was able to find a thread from 2017 with a workaround to use the advanced mode to copy the subtasks when cloning a Task.

Currently, it's not possible to do this automatically because there is no option to select to copy the subtasks.

 We are tracking the ability to clone subtasks automatically at - AUT-335

In the mean time, you can mnaully loop over the sub-tasks of the original issue and clone these. You will need to overwrite the parent in the advanced section with:

{
    "fields": {
        "parent": "{{createdIssues.first.key}}."
    }
}

This will set the parent of the cloned issue to the first issue created in the rule - in this case the original clone.

Please, give it a try and let us know how it goes.

Regards,
Angélica

Rick Crow
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.
June 5, 2020

Hi @Angélica Luz, I ran across the same 2017 post that seemed to be exactly what I was looking for. Unfortunately, then I realized that the resulting cloned subtasks had the reverse rank order as compared to the original list of subtasks. This is especially problematic for our use case as there are over 100 subtasks and the order is critical. Manually re-ranking the list is clearly not an ideal solution. Any thoughts?

Jeff Cadow he-him June 10, 2022

Hi, @Angélica Luz - the JSON you included in your Mar 11 2020 reply generated an error for me. The parent property is evidently not a field, it is a root level attribute. I rewrote the JSON as this and it modified the issue's parent:

{
"parent" : "{{createdIssue.key}}"
}

Unfortunately, even though this set the parent value as I hoped it would, the cloned Sub-task still showed up as a child of the original Task instead of a child of the original Task's new clone, as I mention here. If I've uncovered a bug, please reply and I'll create a bug report. Thanks.

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.
June 10, 2022

Hi @Jeff Cadow he-him 

Context is important for automation rules, and so please post images of your entire rule and the audit log details.  That will show which issue is being used as the source for adding the subtask, and what adjustments are needed to fix the symptom.  Thanks!

Kind regards,
Bill

Like Jeff Cadow he-him likes this
Jeff Cadow he-him June 13, 2022

Hi, @[deleted] - Oops - sorry!

I finally got my automation rule to properly link the new Sub-task clones to the new Task clone. It entailed creating a variable to hold the new parent Task.

Screenshot 2022-06-13 160021.png

Like # people like 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.
June 13, 2022

Well done!  You could also do that without the created variable by referencing the value directly as {{createdIssue.key}}

Your version works because created variables are currently text-only, and the default smart value (field) returned for {{createdIssue}} is the key.

In the future, I hypothesize that created variables might preserve the object/type of the source smart value.  For example, text, numeric, list, issue, etc.  If that happens your rule will probably still work due to the default smart value for an "issue", but if it doesn't that may be the problem.

Like Taranjeet Singh likes this
brandon.bradshaw@maritz.com January 5, 2023

@Jeff Cadow he-him @Bill Sheboy This is great, I appreciate the screenshot. I have a slight variation I'm trying to get working and the standard solutions that come to mind seem to just get ignored. My goal is for the Task and Subtask Status to get cloned over as well. My task Status changes correctly, however the cloned Subtask Status is not cloning over correctly.

I have tried just about every Action/Condition within my For Sub-tasks branch but nothing will clone the Subtask Status properly.

Here's a drawing to further explain my delima.

Original Task (Status = To Do)
Original Sub-task (Status = To Do)

 -->

Cloned Task (Status = In Progress)
Cloned Sub-task (Status = To Do)

As you can see the Cloned Task status changes perfectly, but the Cloned Sub-task Status does not follow the workflow. The Cloned Sub-task should now have a status of In Progress.

Like Eric Jahn likes this
Stephen Wright _Elabor8_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
January 8, 2023

Just for visibility, there's also a separate question for Brandon's query :) - see: https://community.atlassian.com/t5/Jira-Software-questions/Cloned-Sub-task-not-copying-proper-Status/qaq-p/2233327

Ste

Eric Jahn January 9, 2024

Likewise, when I clone sub-tasks, the status reverts to the beginning workflow status.  In my case this is the "To-do".  It does not receive the same status of the sub-task it was copied from. I'll create a new ticket for this topic, since I have a simpler scenario than brandon.bradshaw@maritz.com's.

New ticket:

https://community.atlassian.com/t5/Jira-Software-questions/cloned-sub-tasks-do-not-receive-copy-the-original-sub-task-s/qaq-p/2574687

Jonathan Gall June 18, 2023

Thank you for the heads up on this solution; it's perfect!

Eric Jahn January 9, 2024

Does it copy the statuses properly, especially when the status is not "To-do" (the beginning workflow status cloned sub-tasks default to)?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
STANDARD
PERMISSIONS LEVEL
Site Admin
TAGS
AUG Leaders

Atlassian Community Events