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?

miller j Jan 27, 2018


 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
Ivan Tovbin Community Leader Jan 27, 2018 • edited

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*/
QQQ Apr 10, 2018

@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)
Dante Labate Sep 10, 2018

@Ivan Tovbin

could you tell me how I remove link?

Suggest an answer

Log in or Sign up to answer
This widget could not be displayed.
This widget could not be displayed.
Community showcase
Published in Jira

Try Jira Cloud for Outlook: Organize your work without leaving your inbox

Hi Atlassian community, My name is Max and I work on the product integration team at Atlassian. I am pleased to announce the early access program for the Jira Cloud add-in for Outlook. This add-in...

2,046 views 6 15
Read article

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