Dear Jamie,
I'm trying to make a post function script in the workflow to remove the issue links.
My goal is to remove an issue link when the status changes in Project 1 from B (In progress) to C (validation).
Why? There is a syncronizer running between the linked issue in Project 1 and 2. Project 1 is a big management project and project 2 (3, 4, 5, 6 ....) are application backlogs. When an issue is closed in the application backlog then the status in Project 1 can go to "validation". There is a possibility that the validation will disagree with the evidence and rejects the issue and puts it back to "In Progress".
Because we want to keep a history (for training purposes) we don't want to recreate an issue in the application backlog but make a new one. When we're progressing that issue in a new backlog item the other backlog item is also synchronize because it is still linked.
Is there a script that automatically removes the link in project 1 when changing the status from "In progress" to "Validation"? ( >> issueLinkManager.removeIssueLink (issue.getId()) << )
Thanks in advance!
Friendly Regards,
Tom
Community moderators have prevented the ability to post new answers.
Dear Total Company.
You want something like this, completely untested:
import com.atlassian.jira.component.ComponentAccessor import com.atlassian.jira.config.properties.PropertiesManager import com.atlassian.jira.issue.Issue import com.atlassian.jira.issue.link.IssueLink def issueLinkManager = ComponentAccessor.getIssueLinkManager() def user = ComponentAccessor.getJiraAuthenticationContext()?.getLoggedInUser() def linkCallback = {IssueLink link -> if (link.destinationObject.projectObject.key == "SOMEKEY") { issueLinkManager.removeIssueLink(link, user) } } issueLinkManager.getOutwardLinks(issue.id).each (linkCallback) issueLinkManager.getInwardLinks(issue.id).each (linkCallback)
TY Jamie - this worked for a similar scenario, with this example you just have to use 'def user = ComponentAccessor.getJiraAuthenticationContext()?.getUser().getDirectoryUser()' instead - at least now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
right... getUser().getDirectoryUser() should be the same as calling getLoggedInUser() pre jira 7. In jira 7 Atlassian has sorted out the user schizophrenia.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Seeing weird behavior with this though - I log when a link is found in the linkCallback and also when the condition is met. Every time I make the transition the link I want to remove is found and the condition is met. However, the first time I make the transition the link isn't remove (at least on the UI), I have to make the transition again on the issue and then the link gets removed. Any ideas?
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.
Interesting, well I don't know exactly what is causing the issue, but as workaround I'm calling issueLinkManager.getOutwardLinks(issue.id).each (linkCallback) twice and it seems to be working fine now.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Dear Jamie,
Thanks for your response.
Is it possible to only remove one specific link?
I know use;
- Details
- is realized by
- Mentions
Is it possible to only remove the Realizes link?
Friendly regards,
Tom
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yeah you just need to filter further by adding more "if" conditions. For link type use, link.issueLinkType.name or something.
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.