Clone epic, tasks and sub-tasks

Use case

Clone an epic, the tasks under the epic and the sub-tasks of these tasks.

🗒️ Prerequisites

Set up a custom field

  1. Create a Text (single line) custom field

    Name: Template Issue

⚒️ Configuration

Add the first Create issue post function

Add a Create issue post function to the desired workflow transition.

Issue to be created

Mode

Choose Single issue

Issue type

Choose Parser expression (standard issue type) and write the following expression:

Bash
%{issue.issueType}

Summary

Enter the following expression with parsing mode set to Basic text

Bash
CLONE - %{issue.summary}

Additional options

Update the following fields

Epic Name

Choose Parsed text (basic mode) and write the following expression:

Bash
CLONE - %{issue.summary}

Resolution

Choose Parsed text (advanced mode) and write the following expression:

Bash
null

Copy remaining fields

Select From current issue and All remaining fields

Add a Relates to issue link and link it to the current issue

Additional options

Tick Store issue keys

Add a second create issue post function

Add another Create issue post function after the previous post function in the same workflow transition.

Issues to be created

Mode

Choose Multiple issues

Expression

Enter the following parser expression with parsing mode set to Issue list

Bash
issuesUnderEpic()

Issue type

Choose Parser expression (standard issue type) and use the following expression:

Bash
^%{issue.issueType}

Summary

Enter the following expression with parsing mode set to Advanced text

Bash
^%{issue.summary}

Description

Enter the following expression with parsing mode set to Advanced text

Bash
^%{issue.description}

Additional options

Update the following fields

Resolution

Choose Parsed text (advanced mode) and write the following expression:

Bash
null

Choose Field in current issue and Ephemeral String 3

Template issue

Choose Parsed text (advanced mode) and write the following expression:

Bash
^%{issue.key}

Add another Create issue post function after the previous post function in the same workflow transition.

Copy remaining fields

Select From seed issue and All remaining fields

Additional options

Tick Store issue keys

Add a third create issue post function

Add another Create issue post function after the previous post function in the same workflow transition.

Issues to be created

Mode

Choose Multiple issues

Expression

Enter the following parser expression with parsing mode set to Text list

Bash
toStringList(toString(textOnStringList(toStringList(replaceFirst(%{00063}, "^([^,]+,\\s)", ""), ","), toString(textOnStringList(fieldValue(%{issue.cfTemplateIssue}, issueKeysToIssueList(^0%)), findModify(toString(subtasks(^1%)), "[^, ]+",^0% + ":" + ^2%))))), ",")

Replace the field code %{issue.cfTemplateIssue} with the field code of the Template Issue field in your instance.

Issue type

Choose Selected issue type and select Sub-task

Parent issue

Select Set parent manually (parser expression) and use the following expression.

Bash
replaceFirst(^%, ":.*$", "")

Summary

Enter the following expression with parsing mode set to Advanced text

Bash
toString(fieldValue(%{00000}, issueKeysToIssueList(replaceFirst(^%, "^.*:", ""))))

Description

Enter the following expression with parsing mode set to Advanced text

Bash
toString(fieldValue(%{00001}, issueKeysToIssueList(replaceFirst(^%, "^.*:", ""))))

Additional options

Update the following fields

Assignee

Choose Parsed text (advanced mode) and write the following expression:

Bash
toString(fieldValue(%{00003}, issueKeysToIssueList(replaceFirst(^%, "^.*:", ""))))

Due date

Choose Parsed text (advanced mode) and write the following expression:

Bash
first(fieldValue({00012}, issueKeysToIssueList(replaceFirst(^%, "^.*:", ""))))

In this case we cannot use the Inherit field values parameter in the post-function for the creation of sub-tasks. Instead, we must use a different expression for each field that we want to copy into sub-task's clones. The expressions to be used are the following ones.

For Number and Date-Time fields:

Bash
first(fieldValue({issue.cfTemplateIssue}, issueKeysToIssueList(replaceFirst(^%, "^.*:", ""))))

For the rest of the fields:

Bash
toString(fieldValue(%{issue.cfTemplateIssue}, issueKeysToIssueList(replaceFirst(^%, "^.*:", ""))))

Replace the field code %{issue.cfTemplateIssue} with the field code of the Template Issue field in your instance.

In this case we cannot use the Inherit field values parameter in the post-function for the creation of sub-tasks. Instead, we must use a different expression for each field that we want to copy into sub-task's clones. The expressions to be used are the following ones.

For Number and Date-Time fields:

Bash
first(fieldValue({issue.cfTemplateIssue}, issueKeysToIssueList(replaceFirst(^%, "^.*:", ""))))

For the rest of the fields:

Bash
toString(fieldValue(%{issue.cfTemplateIssue}, issueKeysToIssueList(replaceFirst(^%, "^.*:", ""))))

Replace the field code %{issue.cfTemplateIssue} with the field code of the Template Issue field in your instance.


📚 Related use cases