Just a heads up: On March 24, 2025, starting at 4:30pm CDT / 19:30 UTC, the site will be undergoing scheduled maintenance for a few hours. During this time, the site might be unavailable for a short while. Thanks for your patience.

×
Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Cloning issue direction

werner kolze November 15, 2018

Hi all - 


I have a rather large script which does a lot of stuff and I get it to work bit by bit - 

this last part is supposed to create a link to a cloned issue - which is does but in the wrong direction

I want to achieve that it creates an outwards pointing link 

             From the Parent to the Cloned issue

so in the PARENT ISSUE I would like to see:

   "is cloned by"  - to my definiton an "outward pointing link"

so I tried this
for (IssueLink link in linkManager.getOutwardLinks(issue.id)) {

and the CLONED ISSUE should have

         "clones"   - to my definition an "inward pointing link"

so I tried this
for (IssueLink link in linkManager.getInwardLinks(issue.id)) {

 

But I cannot get it to do this - 

It always places a 

 "clones" in the PARENT ISSUE

and a 


"is cloned" into the CLONED ISSUE

 

 [ START OF SCRIPT SNIPPET ]

def sequence = 0

for (IssueLink link in linkManager.getOutwardLinks(issue.id)) {

if ("Cloners" == link.issueLinkType.name)
{
sequence++;
}
}

Collection<IssueLinkType> issueLinkTypes = linkTypeManager.getIssueLinkTypes()
String linkID=null;
for (IssueLinkType issueLinkType : issueLinkTypes)
{
String name=issueLinkType.getName();
if(name.equals("Cloners"))
{
linkID=issueLinkType.getId();
break;
}
}

Long issueID = new Long(issue.id).longValue();
Long newissueID = new Long(newissue.id).longValue();
Long TheLinkID = new Long(linkID).longValue();
Long TheSequence = new Long(sequence).longValue();

linkManager.createIssueLink (issueID, newissueID,TheLinkID, TheSequence, currentUser)

 [ END OF SCRIPT SNIPPET ]


Any hint be very much appreciated

thanks a lot

Werner

 

1 answer

1 accepted

0 votes
Answer accepted
Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 16, 2018

Hi

have you tried reversing the issue ids in call

linkManager.createIssueLink (newissueID, issueID, TheLinkID, TheSequence, currentUser)
werner kolze November 18, 2018

Hi Tom - your suggestion indeed turned it upside down - the right way - thanks a lot
 - I did not think it would make a difference, but never tried - I should have tried.

Thanks again.

Tom Lister
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
November 19, 2018

Great news

could you mark as answered for others to find

werner kolze November 20, 2018

Hi Tom, I thought I did press the answer button - but it did not work - I have to use a different browser to get this functionality. It is the same for the REPLY button - it does not show in Internet Explorer - only in Firefox.

cheers

Suggest an answer

Log in or Sign up to answer