Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Remove issue links of clones for linked issue type story

srinivas kattla January 15, 2020

Hello,

I'm planning to remove the linked issues of type clones for the linked issue type story and linked issues is from any projects .I was able to remove the issue links for issuelink type cloners but not able to make for the linked issues linked from other projects with linked issue type story.

Here is my code .But my code removes all links even condition is added .I'm looking some thing to check the linked issue status before remove. suggestion please

 

port com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.link.IssueLink
import com.atlassian.jira.issue.link.IssueLinkManager
import com.atlassian.jira.user.ApplicationUser

ApplicationUser loggedInUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser
IssueLinkManager issueLinkManager = ComponentAccessor.getIssueLinkManager()
issueLinkManager.getInwardLinks(issue.getId()).each {issueLink ->
if (issueLink.getIssueLinkType().getName().equals("System Test Execution") && issue.issueType.name == 'Story'){
issueLinkManager.removeIssueLink(issueLink, loggedInUser)
}
}

1 answer

0 votes
Joaquin Fernández Morales
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
January 17, 2020

Hi srinivas kattla,

 

Maybe this script could be useful for you, you must configure the jql sentence to treat those issues you want to change,  in this code I have eliminated the "cloners" link in all issues for the project "YOURPROJECT": 

 

import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.issue.Issue
import com.atlassian.crowd.embedded.api.User
import com.atlassian.jira.bc.issue.search.SearchService
import com.atlassian.jira.component.ComponentAccessor
import com.atlassian.jira.issue.Issue
import com.atlassian.jira.issue.IssueManager
import com.atlassian.jira.user.ApplicationUser


String jqlSearch = ("project = YOURPROJECT");
SearchService searchService = ComponentAccessor.getComponent(SearchService.class)
ApplicationUser user = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
IssueManager issueManager = ComponentAccessor.getIssueManager()

List<Issue> issues = null

SearchService.ParseResult parseResult = searchService.parseQuery(user, jqlSearch)
def issueLinkManager = ComponentAccessor.getIssueLinkManager()

def aux
issues.each {issue->
issueLinkManager.getOutwardLinks(issue.getId())?.each() { link ->
//aux = link.getIssueLinkType().getName()
if (link.getIssueLinkType().getName().equals("Cloners")){
//aux = link.getDestinationObject()
issueLinkManager.removeIssueLink(link, user);
}
}
}

 

 

Please, be careful and running the above code with a small group of issues first or in a test instance. 

 

If you need more help you can open a ticket here:

https://productsupport.adaptavist.com/servicedesk/customer/portal/2

 

 

Kind Regards, 

Joaquín

Stan Murrah March 26, 2021

Why doesn't Jira allow bulk edit of issue link type or issue link so that we can delete the link using the bulk edit?  That way we wouldn't have to write our own code to do this.

Suggest an answer

Log in or Sign up to answer