Help with Jira Automation to clone and edit epics with its child issues
Asked by Hakim Belkouch:

Hello,

This[article](https://community.atlassian.com/t5/Jira-articles/Clone-Epic-Stories-and-Subtasks-tree-with-Jira-Automation/ba-p/2316387) helped me create a manual Automation Rule to clone epics with its child issues.It's a really useful way to do something a lot of my users have been asking for.

However I would also like to edit the summary of the cloned issues. Each issue starts with a prefix and version. And I'd like to increment the version of the cloned issues.

An example if my epic and child have this as a summary :

ABC 2.1 Epic

ABC 2.1 Child issue 1

ABC 2.1 Child issue 2

I'd like the summary of the cloned epic and cloned child issues to be :

ABC 2.2 Epic

ABC 2.2 Child issue 1

ABC 2.2 Child issue 3

How can Jira Automation help me do this?

Thank you!


Answers:
author: Bill Sheboy
body: Hi [@Hakim Belkouch](/t5/user/viewprofilepage/user-id/5380832)

Without seeing your complete rule for context...

Where is the number value you want to increment? It appears to be part of the Summary of the first issue (i.e., the Epic) to be cloned.

In that case, you could use text functions, such as match(), to extract the value from the Summary, save it in a variable, and then use math functions to increment it for updating in issues. Please look here to learn the functions to support doing this:

* <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-text-fields/>
* <https://support.atlassian.com/cloud-automation/docs/jira-smart-values-math-expressions/>

Kind regards,  
Bill

comments: author: Hakim Belkouch
body: Hi Bill,

This is what I used for my variable block that I called X :

{{{{issue.summary.substring(7,8)}}.asNumber}}.plus(1)

And this is what I used for the summary of the clone epic block :

{{issue.summary.replace({{issue.summary.substring(7,8))}},{{X}})}}

I'm new with smart values as you can tell, am I using the right format?

Thank you!


author: Bill Sheboy
body: You have some extra curly brackets in that expression to get the number:

{{issue.summary.substring(7,8).asNumber.plus(1)}}

To combine that with the other value, grab the left part first, followed by the number, and then followed by the right part:

{{issue.summary.left(6)}}{{issue.summary.substring(7,8).asNumber.plus(1)}}{{issue.summary.substring(9,issue.summary.length())}}

These assume a fixed format for the Summary.


author: Hakim Belkouch
body: Thank you this helped me! I managed to do it


author: Luka Hummel - codefortynine
body: Hello [@Hakim Belkouch](/t5/user/viewprofilepage/user-id/5380832)

It sounds like you're looking for a streamlined solution to clone and modify epics and child issues while also incrementing values within summaries. Our app [Deep Clone for Jira](https://marketplace.atlassian.com/apps/1218652?utm_source=atlassian&utm_medium=referral&utm_campaign=deepj-new-reach-com-2820591) could help simplify your workflow. It allows you to clone issues along with their child structures, while you could configure adjustments like replacing the version in your summary in combination with the [Field Editor](https://documentation.codefortynine.com/deep-clone-for-jira/field-editor?utm_source=atlassian&utm_medium=referral&utm_campaign=deepj-new-reach-com-2820591) feature.

![2024-09-25 10-04.png](https://community.atlassian.com/t5/image/serverpage/image-id/349187i0C8B19BD33E855B7/image-size/large?v=v2&px=999 "2024-09-25 10-04.png")

This might save you some effort, especially for bulk or frequent cloning tasks!


author: Katja Kaiser
body: Hello Hakim,

maybe this article could help you.

<https://confluence.atlassian.com/jirakb/how-to-automatically-increment-assets-integer-attribute-using-automation-for-assets-1168848373.html>


Tags: cloud

jira-automation

jira-cloud

json

smart-value