Hello,
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.
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*/
Hi Ivan,
I did try to run this in script console instead of post function, but got some error on
linkMgr.createIssueLink
can't find match method
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.