De- Linking an Issue

i am writting an Groovy Script for post function, My question is: I have created a issue link, now on certian transition i want that link to get De-Link, So for it My approach is to grab that issue link and then do the de-link for both the issues. But i don't know how to grab the Issue Link ID.

Can any of thee geniouses out there can help me out?

2 answers

1 accepted

This widget could not be displayed.

to get the issue link id's bi-directionally as follows

to get OUward links

List<IssueLink> allOutIssueLink = issueLinkManager.getOutwardLinks(sourceIssue.getId());
for (Iterator<IssueLink> outIterator = allOutIssueLink.iterator(); outIterator.hasNext();) {
	IssueLink issueLink = (IssueLink) outIterator.next();
	System.out.println(issueLink.getIssueLinkType().getId());	
}

same way to get inword issueLink's

List<IssueLink> allInIssueLink = issueLinkManager.getInwardLinks(sourceIssue.getId());
for (Iterator<IssueLink> inIterator = allInIssueLink.iterator(); inIterator.hasNext();) {
	IssueLink issueLink = (IssueLink) inIterator.next();
	System.out.println(issueLink.getIssueLinkType().getId());
if (issueLink.getIssueLinkType().getId() == 10) {
Issue destinationIssue = issueLink.getDestinationObject();
}
 }

Once i gether the issue links,

I want to delink it and make the associated issue to move back to some other status.

I have tried using Inward issue, I am getting the Inward issue name and ID but i want an issue which is linked to it, So any thoughts on it?

you have to use following code to get linked issues

Issue issue=issueLink.getDestinationObject();

check my answer i have update the inword issuelink code

This widget could not be displayed.

i have already given code to delink right?

issueLink = issueLinkManager.getIssueLink(sourceId, destId, linkType);
 
issueLinkManager.removeIssueLink(issueLink , remoteuser);

is it not worked?

Rambanam: Yes, I know and have implemented it and its working perfectly fine, since i have used Customfield plugin on 1 issue type through whcih i used to gather that custom field and make it as mutable issue and perform operations, But this plugin was implemented only on 1 issue type but i am trying to write a groovy script for other issue type, such that Bi-Directional functionality works,

So now since i have created a links between 2 issues, I want to grab issue link ID and then perform operations like setting Status and delinking.

So my motive is:

1) Gather the linked issue
2) Gather the current status of the issue
3) Look about the other linked status of the issue
4) Replace the issue's status from the current to the newest status (that you are looking to place)
5) update the issue

you are asking about delink or move status?

So any thoughts about this.

I am trying to use the inward link but still its giving me the link name and ID of itself,

my code goes like this:



log.warn("Current Issue is : " + issue)

List<IssueLink> allInIssueLink = linkManager.getInwardLinks(issue.getId());
for (Iterator<IssueLink> inIterator = allInIssueLink.iterator(); inIterator.hasNext();) {
IssueLink issueLink = (IssueLink) inIterator.next();
log.warn("Issue Link Type is : " +issueLink.getIssueLinkType().getId());
log.warn("Issue Link Name : " + issueLink.getIssueLinkType().getName())
Issue issue1= issueLink.getDestinationObject()
}


Collection<IssueLinkType> issueLinkTypes = ((IssueLinkTypeManager) ComponentManager
.getComponentInstanceOfType(IssueLinkTypeManager.class)).getIssueLinkTypes();
String linkID=null;
for (IssueLinkType linktype : issueLinkTypes) {
String name=linktype.getName();
if(name.equals("Open Position - Candidate Ticket")){
linkID=linktype.getId();
break;
}
}


}


OpenPositionFinalVersion(issue)

did you print issue1 object?

try somethink like this

List&lt;IssueLink&gt; allInIssueLink = linkManager.getInwardLinks(issue.getId());
for (Iterator&lt;IssueLink&gt; inIterator = allInIssueLink.iterator(); inIterator.hasNext();) {
IssueLink issueLink = (IssueLink) inIterator.next();
log.warn("Issue Link Type is : " +issueLink.getIssueLinkType().getId());
log.warn("Issue Link Name : " + issueLink.getIssueLinkType().getName());
Issue issue1= issueLink.getDestinationObject();
log.warn("issue1 : " + issue1);
if(issue1!=null){
log.warn("issue1 Key: " + issue1.getKey());
}
}

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted yesterday in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

53 views 1 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you