Automation Rule - How to remove watchers for epic-linked issues which were cloned with its Epic?
Asked by Tilman Ulshoefer:

Dear everyone,

<br />

I have a rule where I clone an Epic, including the epic-linked issues. I successfully remove the watcher from the cloned Epic, using the branch "For All created issues".

**How do I configure the rule correctly, so that the watchers are also removed from the cloned epic-linked issues? Why does the branch in the screenshot not remove the watchers from the cloned epic-linked issues as well, as its name implies?** I tried a lot of things and still fail.

![2024-05-14_14-05-39.png](/t5/image/serverpage/image-id/323597iBB48C8DE928C2D01/image-dimensions/199x326?v=v2 "2024-05-14_14-05-39.png")


Answers:
author: Bill Sheboy
body: Hi [@Tilman Ulshoefer](/t5/user/viewprofilepage/user-id/4740875)

Yes, and...to Kalyan's suggestions:

Branches which could be on [more-than-one-thing are run in parallel and asynchronously, with no guarantee of when the branch will finish](https://support.atlassian.com/cloud-automation/docs/jira-automation-branches/#Ordering-of-branch-executions)...up until the last step of the rule. This design helps quite a bit with rule performance, and requires us to think differently when writing rules :\^)

In your rule's branch to *Stories or other issues in the Epic* , all of those loops of processing happen independently of the main rule path; same thing with the later branch on *All created issues* . And so the child issue clones are not visible *outside of the branch* for any use in the recently created issues branch.

Worse still, I hypothesize the second branch in your rule is likely to finish before all of the issues are cloned!

There are a few workarounds for this scenario, depending upon if you want to remove all watchers, or some of them, from the clones...

* Remove all watchers
  * Rather than using the clone issue action, use create issue and only include the needed fields when copying. Then no removal of watchers is needed.
* Remove some watchers
  * Use a second rule, triggered on issue created, which detects cloning and selectively remove watchers.

Kind regards,  
Bill

comments: author: Tilman Ulshoefer
body: Thank you Bill, you helped me a lot to find the solution now:  

A scheduled event running every morning, where I select all issues with a certain text in the summary field, and then to remove specific watchers.  

Why this solution?

* I did not find out how to create an issue and copy field values from a source Epic plus its epic-linked issues
* Having a second, separate rule, triggered with "Issue Created" or "Multiple issue events" did not work. The rule does not run, meaning, the previous Clone Rule does not trigger an Issue Created event!


author: Bill Sheboy
body: Well done; please remember to fully test your rule to confirm it works as expected.

Regarding the challenges you encountered...

For the first concern, one approach is saving data which is needed later and using the correct smart values. For example, by saving the newly cloned Epic's key in a variable for later use from {{createdIssue.key}}

For the second one, by default the actions of one rule cannot trigger another rule. This prevents unintended consequences and run-away looping errors. When you actually want the actions of one rule (e.g., create an issue) to trigger another rule, the *downstream rule* can [enable the option "Allow Rule Trigger" in the details at the top](https://support.atlassian.com/cloud-automation/docs/create-and-edit-jira-automation-rules/#Edit-the-details-of-a-rule). Use caution with this option to confirm it does not cause problems.


author: Kalyan Sattaluri
body: Hello [@Tilman Ulshoefer](/t5/user/viewprofilepage/user-id/4740875)

What you are seeing is expected behavior.

The last branch where you are removing watchers..

* will remove the watcher from from the Epic created right after your If statement
* will NOT remove watcher from stories created in an earlier branch.

Because the "created issues from previous steps in the rule" branch, your last step, has no visibility on stories created in your earlier branch, except the issues created as part of the main rule.

Instead, you should have the "Remove watchers" statement right after you are cloning the issues so you dont even need this last branch.

Finally, you maybe aware, but stating it for clarity, if you want to clone an epic, including its stories, that is, create a new epic and new set of stories underneath it, your current rule is not doing that. Yes, you are creating a new epic, but you are cloning stories under old epic.

comments: author: Tilman Ulshoefer
body: Thank you for your advice, Kalyan,.  

Unfortunately, moving remove watchers into the branch leads to removing the watchers from the source epic. And having the remove watchers at the last step at least removes them from the cloned Epic (I removed the last branch, remove watchers work fine for the Epic without this branch).  

The questions with the cloned epic-link issues persists, therefore, I will now try out what Bill suggests.  

BTW: the epic-linked issues are nicely cloned and associated to the cloned Epic, that works fine.


author: Jack Brickey
body: Hi [@Tilman Ulshoefer](/t5/user/viewprofilepage/user-id/4740875) ,

You should move that last branch under the previous branch right after the clone issues action under the first branch. You may need to add a "refetch data" after clone action.

comments: author: Tilman Ulshoefer
body: Thank you for your advice, Jack.  

Unfortunately, moving (including refetch) remove watchers into the branch and also, right after the main one (then: clone...) leads to removing the watchers from the source epic and issues, not the cloned ones.

I will now try out what Bill suggests.


Tags: cloud