Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
4,363,064
Community Members
 
Community Events
168
Community Groups

How to bulk delete a specific Linktype

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.

1 answer

1 accepted

0 votes
Answer accepted

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.

Hi @Mohamed Mehdi Mrad

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:-

config1.png

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:-

issue_linking_config.png

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.

test1.png

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.

test2.png

 

I hope this helps to answer your question. :)

Thank you and Kind regards,

Ram 

Hi @Mohamed Mehdi Mrad

Does this answer your question?

If yes, please accept the answer provided.

 

Thank you and Kind regards,

Ram

Hello,

Yes this is indeed what I want to do, thank you for your answer.

Regards,

Mehdi.

Suggest an answer

Log in or Sign up to answer
TAGS

Atlassian Community Events