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,
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?
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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); } }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.