On this page

Use case

Create automatically a sub-task under the parent of a sub-task that has just been closed, increase a number in the summary of the new sub-task and copy all the fields, attachments and comments from the previous sub-task.

Prerequisites

Set up custom fields

Create a Select list (single choice) custom field

Name: Create another sub-task

Options: Yes and No


Configuration

Add a Create issue post function to the final transition of the sub-tasks workflow.
Issues to be created

Mode

Choose Single issue.

Issue type

Choose Selected issue type

Specific issue type

Choose Sub-task.

Parent issue

Choose Select parent manually (parser expression) and add the following expression manually in Issue list mode:

issueKeysToIssueList(%{parent.key})

Summary

Enter the following expression with the expression editor in Advanced text mode:

findReplaceFirst(%{issue.summary}, first(findPattern(%{issue.summary}, "[0-9]+")) , toString(sum([toNumber(first(findPattern(%{issue.summary}, "[0-9]+"))), 1])) )

This expression will take the first number written in the summary of the transitioned sub-task and increase it by one unit in the summary of the new issue.

This expression is only valid if a number is added to the summary of the sub-tasks to serialize them as in a summary like "Sub-task number 1 - Create issue post function".

Description

Enter the following expression to inherit the description of the transitioned sub-task.

%{issue.description}

Copy remaining fields

Select From current issue and check all of the options of the checkbox.

Conditional execution

Add the following expression for the conditional execution after replacing the field code %{issue.cfaaaaa} with the one for the Create another sub-task field.

%{issue.issueType} = "Sub-task" and %{issue.cfaaaaa} = "Yes"

If you still have questions, feel free to refer to our support team.