Automation Rule: Add a Cloned Epic parent to its Story
Asked by Emna Elleuch:

How can I add an automation Rule to add the Cloned item as Parent.

basically, I have created a Rule, whenever a new Story is created, A new Epic will be added as clone to that Story. Now I would like to add a Rule/ or maybe edit the first one to edit the Story and add the Epic Cloned as parent to the Story?

is it possible to do that?

Thanks in advance !

![Clone Epic.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/335847iB30EDE13618F9A68/image-size/large?v=v2&px=999 "Clone Epic.PNG")


Answers:
author: Bill Sheboy
body: Hi [@Emna Elleuch](/t5/user/viewprofilepage/user-id/4862258)

Yes, that is possible.

However, do you always want to do this, for every single Story created? Or, is there some set of conditions to decide when to also create the Epic?

When an issue is created in a rule, the [smart value {{createdIssue}}](https://support.atlassian.com/cloud-automation/docs/jira-smart-values-issues/#--createdIssue--) may be used to access its fields. And so after you clone your issue into the epic, the parent field could be set.

For example:

* trigger: issue created
* action: re-fetch issue *(The issue created trigger can fire so quickly that some data may not yet be available to the rule. To prevent errors / unexpected behaviors, I recommend always adding the Re-fetch Issue action immediately after this trigger.)*
* condition: issue type equals Story
* action: clone issue, to create the Epic
* action: edit issue (This will edit the trigger issue...)
  * setting the parent field to {{createdIssue.key}}

Kind regards,  
Bill

comments: author: Emna Elleuch
body: Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) ,

Yes I want to always clone the Story and add it as Epic. Your solution works for me thanks a lot, what about now this workflow is it possible to do it? Should i update the same Rule or mayeb add a new one? ![new rule.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/336049iC2A05B186D68957E/image-size/large?v=v2&px=999 "new rule.PNG")thanks in advance Bill

After cloning the Story to an Epic, I have some Dev/Qa Stories and Bugs linked/Related to the Story, I would like to add the Epic Cloned as Parent.

Epic Cloned Parent to all Dev/QA Stories and Bugs.


author: Emna Elleuch
body: i've tried this rule but it didnt work , whenever the Parent of the Story changed, we will look to its linked issues (Bugs/QA Stories or DEV Story) and edit their PArent to be similar than the Trigger

am I doing it wrong? thanks

![don't work.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/336053i156A75587E41202B/image-size/large?v=v2&px=999 "don't work.PNG")


author: Bill Sheboy
body: Please review the solution I suggested, as it appears you have the Re-fetch Issue action in the incorrect location: <https://community.atlassian.com/t5/Jira-questions/Re-Automation-Rule-Add-a-Cloned-Epic-parent-to-its-Story/qaq-p/2756322/comment-id/1034373#M1034373>

For your second scenario where the Story's Parent changes and you also want to add that same Parent to any linked "relates to" issues...

By default, the actions of one rule do not trigger other rules. This is to prevent accidental rule looping problems.

And so when your rule to create the Epic runs and sets the Story's parent, the second rule does not trigger / run. You can correct that by updating the Rule Details at the top of the second rule, enabling this option with the checkbox:

*Check to allow other rule actions to trigger this rule...*


author: Emna Elleuch
body: Thank you [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313) I've fixed the rule and used your solution, thanks for your help!


Tags: cloud

jira-cloud