Script to remove outward links

Rilwan Ahmed
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 3, 2024

When we use Script runner "Clones an issue, and links" post function, the newly created tickets get all the links from source ticket. Is there a way to not to link this ?

Example:
I have created links "relates to ABC-001" and "Implements ABC-002" for ABC-123. From ABC-123, I am creating XYZ-456 using script runner "Clones an issue, and links" post function. The problem is, XYZ-456 also gets "relates to ABC-001" and "Implements ABC-002" . I don't want to see this.

I want only ABC-123 linked to XYZ-456

2 answers

1 accepted

1 vote
Answer accepted
Laurie Sciutti
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 3, 2024
Rilwan Ahmed
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 4, 2024

Thanks @Laurie Sciutti , this worked. 

Like Laurie Sciutti likes this
0 votes
Ram Kumar Aravindakshan _Adaptavist_
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 4, 2024

Hi @Rilwan Ahmed

For your requirement, I suggest looking into ScriptRunner's HAPI unlink feature.

You can try something like the code below in the ScriptRunner Console:-

import com.adaptavist.hapi.jira.issues.Issues

def issue = Issues.getByKey('MOCK-1') // Change issue key

issue.outwardLinks.each {
issue.unlink('relates to', it.destinationObject) // change link type
}

Please note that the sample working code above is not 100% exact to your environment. Hence, you must make the required modifications.

Below is a screenshot of the configuration:-

example.png

If you observe the screenshot above, the code works and returns the expected output.

When doing this Clone Issue and Links Post-Function, you can use the Condition field and just add:-

issue.outwardLinks.each {
issue.unlink('relates to', it.destinationObject) // change link type
}

I hope this helps to solve your question. :-)

Thank you and Kind regards,
Ram

Suggest an answer

Log in or Sign up to answer