It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to set issue links through groovy in script postfunction?


 I am trying to set the issue links though post functions using groovy. I would like to create the links based on a custom field value from the current issue to the new issue.

def customField = ComponentAccessor.getCustomFieldManager().getCustomFieldObject('<customfield_id>')

def customFieldValue = issue.getCustomFieldValue(customField)

def newIssue = 'abc-123'

if(customFieldValue  = 1){

Link blocks


else {

Link clones



Thanks a mill.


1 answer

1 accepted

2 votes
Answer accepted

Here's how you do it.

def currentUser = ComponentAccessor.getJiraAuthenticationContext().getLoggedInUser()
def linkMgr = ComponentAccessor.getIssueLinkManager()
linkMgr.createIssueLink(11111, 22222, 33333, 1, currentUser)

/*where 11111, 22222 and 33333 are source issue id, destination issue id and issue link type id respectively */
/*currentUser is the link creator, so feel free to change it to any other Application User object*/

@Ivan Tovbin

Hi Ivan,

I did try to run this in script console instead of post function, but got some error on


 can't find match method

Ivan Tovbin Community Leader Apr 10, 2018

It's the usual thing with Scriptrunner's Static Type Checking not always being accurate. 

In this very case you can either simply ignore this error - the code will work just fine. Or you can declare argument types like so, to make the error go away:

linkMgr.createIssueLink((Long)11111, (Long)22222, (Long)33333, (Long)1, currentUser)

@Ivan Tovbin

could you tell me how I remove link?

Suggest an answer

Log in or Sign up to answer
Community showcase
Posted in Portfolio for Jira

Program managers, we need your help! We want to learn about how you plan work for a team of teams

Hi community members, My name is Erika and I’m a product manager at Atlassian. We’re currently investigating how teams are planning work at the program level. We understand that every team in a tea...

145 views 0 5
Join discussion

Community Events

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

Find an event

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

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you