Can I use automation to change linked issues link type?
Asked by Frederik Vindum:

My challange is this: in a Jira cloud project a number of tasks have been cloned. This results in each issue having a summary field prefixed with "CLONE" and an issue link of type "clones" which references the issue it was cloned from. I would like to create an automation rule that could convert the issue link type from "clones" to "related to".

I have successfully created a rule that for a single issue could do that; however, I dont't want to open all issues one after the other to apply the rule. I want to be able to apply a rule that will fix all issues in the same time. As nested branches are not supported I doubt it is possible. Any thoughts? Any hints to provide another approach? I have looked at little at python for jira which seems to support the looping mechanism needed but I would rather stay entirely inside Jira.


Answers:
author: Marlene Kegel - codefortynine
body: Hi [@Frederik Vindum](/t5/user/viewprofilepage/user-id/4386740),

I'm Marlene from [codefortynine.](https://marketplace.atlassian.com/vendors/1213041/codefortynine-gmbh)

If you are not able to find a suitable solution with Jira Automation, you could try our Marketplace app [Deep Clone for Jira,](https://marketplace.atlassian.com/apps/1218652/deep-clone-for-jira?hosting=cloud&tab=overview&source=community197) which - I believe - covers your use case.

With Deep Clone you can

* [Bulk Clone](https://c49.link/deep-clone-for-jira/docs/bulk-clone) several issues at once
* Remove or change the prefix "CLONE-" while Bulk Cloning
* Change the "clones" issue link type to "relates to" while Bulk Cloning

![deep-clone-jira_advanced-options.png](https://community.atlassian.com/t5/image/serverpage/image-id/176245i35709DEB4409ED8A/image-size/large?v=v2&px=999 "deep-clone-jira_advanced-options.png")

You would simply have to

* Filter for the issues you want to bulk clone using the advanced issue search
* Click on the Bulk Clone button
* Uncheck "prefix summary" and configure "Add issue link between clone and original issue" under "advanced option" in the Deep Clone Bulk Clone cofiguration.

comments: author: Frederik Vindum
body: Hi [@Marlene Kegel - codefortynine](/t5/user/viewprofilepage/user-id/2498951)

Thank you for getting back to me and pointing me in an interesting direction. Seems your product can help me. I'll be sure to check it out; however, I have moved on with reating my own Jira Automations.

/Frederik


author: Marlene Kegel - codefortynine
body: Thank you for your feedback, [@Frederik Vindum](/t5/user/viewprofilepage/user-id/4386740)! I am happy to hear that you were able to solve your problem with help of the Atlassian Community :)


author: Bill Sheboy
body: Hi [@Frederik Vindum](/t5/user/viewprofilepage/user-id/4386740)

First thing, would you please share an image of your rule? Did you somehow edit the link type, or remove/re-add the links with the type you want?

Next, to process the existing issues you could:

* copy your current rule
* change the trigger to scheduled (e.g. once per hour) with JQL, looking for issues which have the clones link
* let them process, up to 100 issues at a time due to automation rule limits...
* and let the rule schedule run until it no longer finds issues

Kind regards,  
Bill

comments: author: Frederik Vindum
body: ![02-JqlBranch.png](https://community.atlassian.com/t5/image/serverpage/image-id/174411i6206DDD68698EF62/image-size/large?v=v2&px=999 "02-JqlBranch.png")![01-RuleForSingleIssue.PNG](https://community.atlassian.com/t5/image/serverpage/image-id/174412i083B585CB2AA1D4C/image-size/large?v=v2&px=999 "01-RuleForSingleIssue.PNG")Hi [@Bill Sheboy](/t5/user/viewprofilepage/user-id/1685313)

Tx for the quick reply. I have attached the basic rule (attachment 01) which applies to a single issue. The problem is two things: 1) the rule only applies to one issue (as oppossed to looping through all issues) and 2) in the last step "Link issue to" I must target the triggering issue (or newly created or a smart value {{lookupIssues}}).

My task is this:

*For each issue in project:*

*Remove "CLONES" from issue summary*

*Add link of type "Reletes to" between current issue and issue it was cloned from*

*Remove link of type "Clones"*

My approach has been to use a manual trigger combined with a JQL branch (attachment 02). This should give me the *For each* -part. The summary adjustment is straight forward but when I attempt to add the *Relates to* -link, I have no handle to the issue that the current issue is cloned from: Trigger issue is not the issue that the current issue is cloned from and if I use the issue which was used to clone current task then that reference would be wrong in the next iteration of the look.

Makes any sense at all?


author: Bill Sheboy
body: Hi [@Frederik Vindum](/t5/user/viewprofilepage/user-id/4386740)

I believe this is still possible, and a bit risky. First I will describe a rule to try, and then some possible issues.

* trigger: scheduled on JQL to find the issues with "CLONE -" in the summary:

```
project = myProjectName AND summary ~ "CLONE /-"
```

* action: edit issue fields to remove "CLONE -" from the summary with {{issue.summary.substringAfter("CLONE - ")}}
* action: re-fetch the issue
* related issues condition: linked issues with "is cloned by" are present
* branch: for linked issues of the type "is cloned by"
  * action: link issue as "relates to" the trigger issue
  * action: re-fetch the isuse
  * action: delete issue link of type "clones"

Some possible risks and challenges:

1. I have not tested this, so please confirm if the link types match your needs and are in the correct directions (e.g. "is cloned by" versus "clones"
2. More importantly, how often do you clone *the same issue* to create others? This rule would remove the link and so may fail if you have that situation.