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.
Hi @Mohamed Mehdi Mrad
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.
For your requirement, you could try the sample code below on the ScriptRunner Console:-
import com.atlassian.jira.component.ComponentAccessordef loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUserdef issueManager = ComponentAccessor.issueManagerdef issueLinkManager = ComponentAccessor.issueLinkManagerdef 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,
Does this answer your question?
If yes, please accept the answer provided.
It looks like you're new here. Sign in or register to get started.