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

Earn badges and make progress

You're on your way to the next level! Join the Kudos program to earn points and save your progress.

Deleted user Avatar
Deleted user

Level 1: Seed

25 / 150 points

Next: Root


1 badge earned


Participate in fun challenges

Challenges come and go, but your rewards stay with you. Do more to earn more!


Gift kudos to your peers

What goes around comes around! Share the love by gifting kudos to your peers.


Rise up in the ranks

Keep earning points to reach the top of the leaderboard. It resets every quarter so you always have a chance!


Come for the products,
stay for the community

The Atlassian Community can help you and your team get more value out of Atlassian products and practices.

Atlassian Community about banner
Community Members
Community Events
Community Groups

Can we create link with current issue using script runner using listener feature

I have one field 'A' that contains details of issue type 'B'.

when I create and add the value in Field A as A1 and related IssuetypeID - B1 

So I want that when issue field A is updated with A2 details old link (i.e.A1) should be update issue and change the issue link as value in custom field A  with specific link type like 'ABC'

I have written following script but it is giving error


import com.atlassian.jira.component.ComponentAccessor

import com.atlassian.jira.issue.Issue



import com.atlassian.jira.user.ApplicationUser

final Issue currentIssue = getIssue(); ApplicationUser currentUser = ComponentAccessor.jiraAuthenticationContext.loggedInUser() def customFieldManager = ComponentAccessor.getCustomFieldManager() def customField = customFieldManager.getCustomFieldObjectByName("Cost Details") def issueKey = issue.getCustomFieldValue(customField) as String def issueLinkManager = ComponentAccessor.getIssueLinkManager() def issueManager = ComponentAccessor.getIssueManager() def issueToLink = issueManager.getIssueObject(issueKey) /*for(final IssueLink link: ComponentAccessor.getIssueLinkManager().getIssueLinks(issue.getId())) {     if(link.getIssueLinkType().getName().equals("Cost Issue Out"))     ComponentAccessor.issueLinkManager.removeIssueLinks(issue, currentUser) } */ Collection<IssueLink> inwardLinks = issueLinkManager.getInwardLinks(currentIssue.getId()); for(final IssueLink issueLink : inwardLinks) {     if(issuelink.getIssueLinkType().getName().equals("Cost Issue Out"))     {         issueLinkManager.removeIssueLink(issueLink, context.getLoggedInUser());     } } issueLinkManager.createIssueLink(,, 10840, 1, currentUser)



1 answer

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.
Apr 20, 2023

Hi @Riya Badlani

For your requirement, you could try something like this:-

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

def issue = event.issue
def currentIssue = Issues.getByKey(issue.key)
def sampleIssuePicker = currentIssue.getCustomFieldValue('Sample Issue Picker')
def inwardLinks = currentIssue.inwardLinks
def linkedIssues = inwardLinks.sourceObject

if (linkedIssues.size() > 0) {
inwardLinks.each {issueLink ->
linkedIssues.each { linkedIssue ->
issue.unlink(issueLink.issueLinkType.inward.toLowerCase(), linkedIssue)

if (sampleIssuePicker) {
currentIssue.update {
def links = sampleIssuePicker.collect { Issues.getByKey(it as String) }
setLinks('is blocked by', *links)

Please note the sample code provided is not 100% exact to your environment. Hence, you will need to make the required modifications.

Below is a screenshot of the Listener configuration:-


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

Thank you and Kind regards,


Hi Ram,

Thanks. I will check and let you know if further help is needed.


Best Regards,

Riya Badlani

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.
Apr 26, 2023

Hi @Riya Badlani

Has your question been answered?

If yes, please accept the solution.

Thank you and Kind regards,


Hi @Ram Kumar Aravindakshan _Adaptavist_,

Thanks for asking.

No it is not working for me.

But Resolved it by JWME, Event based action functionality by using different code for create link and execute unlink Issue post function which condition execution.

Suggest an answer

Log in or Sign up to answer
AUG Leaders

Atlassian Community Events