Delete linked issue when delete the original issue

José Manuel González February 15, 2016

Hello,

I'm trying to delete a linked issue, when I delete the original issue. I mean, I got a issue cloned and I want to delete both of them. I'm using a custom listener with ScriptRunner and this is my code.

 

import com.atlassian.jira.ComponentManager;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.jira.user.ApplicationUser;
import com.atlassian.crowd.embedded.api.CrowdService;
import com.atlassian.jira.issue.link.IssueLink

def issueLinkManager = ComponentAccessor.getIssueLinkManager()
def CrowdService crowdService = (CrowdService) ComponentManager.getInstance().getCrowdService();
def User currentUserObj = crowdService.getUser("admin")

issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->
        def String linkname = issueLink.issueLinkType.getName();
        if (linkname.equals("Service desk")) {
  issueManager.deleteIssue(currentUserObj.getName(), issueLink.getDestinationObject(),
  EventDispatchOption.ISSUE_DELETED, false);
        }
}

 

I didn't get errors in the log.. but the issue cloned still exists.. How can I solve it?

 

Thanks in advance

Best Regards,

 

 

 

1 answer

0 votes
Vasiliy Zverev
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.
February 15, 2016

There are inward and outward links. Are you sure that you use correct one here: issueLinkManager.getOutwardLinks(issue.id)? Do you loop these issues via this code?

José Manuel González February 15, 2016

Hello @Vasiliy Zverev,

 

The listener is limited to one project. I mean, the linked issue is in a different project and the listener will not be executed when will deleted.

José Manuel González February 15, 2016

I did some changes on my script, but still not working. I didn't get anything in the log..

 

import com.atlassian.jira.ComponentManager;
import com.atlassian.crowd.embedded.api.User;
import com.atlassian.jira.component.ComponentAccessor;
import com.atlassian.crowd.embedded.api.CrowdService;
import com.atlassian.jira.issue.link.IssueLink;
import com.atlassian.jira.issue.Issue;
import com.atlassian.jira.issue.IssueManager;

ComponentManager componentManager = ComponentManager.getInstance()
issueLinkManager = ComponentAccessor.getIssueLinkManager()
CrowdService crowdService = (CrowdService) ComponentManager.getInstance().getCrowdService();
User currentUserObj = crowdService.getUser("ejolgoo")
IssueManager issueManager = componentManager.getIssueManager()


issueLinkManager.getOutwardLinks(issue.id)?.each {issueLink ->
        String linkname = issueLink.issueLinkType.getName();
        Issue issue = issueLink.getDestinationObject()
        if (linkname.equals("Service desk")) {
            issueManager.deleteIssue(currentUserObj, issue, EventDispatchOption.ISSUE_DELETED, false);
        }
    }
Vasiliy Zverev
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.
February 15, 2016
  1. You need to make sure that you get loot on requared issues. Try ScroptConsole via ScriptRunner and see this: https://answers.atlassian.com/questions/32982259

 

JamieA
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.
February 22, 2016

Can you print out the link type name and make sure it exactly matches the link type name. Perhaps add a screenshot of the "Issue Linking" config.

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events