Hi,
I'm trying to bulk delete a specif issue link type for a project using ScriptRunner following this guide.
But It keeps deleting every links available on the project, can someone help me to refine it only deletes a specific link.
The example provided in this discussion is to remove all links associated with one issue.
Could you please specify what link types you are trying to remove?
Thank you and Kind regards,
Ram
Hello,
I want to delete only a specific type of link (exp: "created by") not all of them.
Thank you.
Regards.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
For your requirement, you could try the sample code below on the ScriptRunner Console:-
import com.atlassian.jira.component.ComponentAccessor
def loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
def issueManager = ComponentAccessor.issueManager
def issueLinkManager = ComponentAccessor.issueLinkManager
def issue = issueManager.getIssueObject('MOCK-1')
issueLinkManager.getOutwardLinks(issue.id).each {
if (it.linkTypeId == 10202) { // Issue Link Type
issueLinkManager.removeIssueLink(it, loggedInUser)
}
}
Please note that the sample code provided is not 100% exact to your environment. Hence, you will need to make the required modifications.
If you observe the sample code above, a link type id is used to identify the specific link that is to removed from the particular issue MOCK-1.
Below is a screenshot of the ScriptRunner console:-
To identify the link type id, you will need to go to the Issue Link type page and place the mouse of ver the edit link as shown below:-
In the sample code provided, I am testing it with the Causes / Is Caused By Issue Link Type.
Below are a few test screenshots for your reference:-
1. First, when the ticket is created, two types of Issue Links are added, i.e. causes and relates to.
2. Upon running the code in the ScripRunner Console, as expected, only the cases link has been removed, and the relates to link is still retained.
I hope this helps to answer your question. :)
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Does this answer your question?
If yes, please accept the answer provided.
Thank you and Kind regards,
Ram
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello,
Yes this is indeed what I want to do, thank you for your answer.
Regards,
Mehdi.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Ram Kumar Aravindakshan _Adaptavist_ , This works for me if i want to delete links of a given link type from a single issue, but how would you modify the script to iterate through a list of issues resulting from a JQL query/saved filter?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.